The error in the log viewer does not give much information on what to do... I'll paste it here (pardon the length)
System.ArgumentException: Path must start with a slash.
Parameter name: path
at Umbraco.Core.UriExtensions.Rewrite(Uri uri, String path)
at Umbraco.Web.Routing.DefaultMediaUrlProvider.AssembleUrl(String path, Uri current, UrlMode mode)
at Umbraco.Web.Routing.DefaultMediaUrlProvider.GetMediaUrl(UmbracoContext umbracoContext, IPublishedContent content, String propertyAlias, UrlMode mode, String culture, Uri current)
at Umbraco.Cloud.StorageProviders.AzureBlob.CdnMediaUrlProvider.GetMediaUrl(UmbracoContext umbracoContext, IPublishedContent content, String propertyAlias, UrlMode mode, String culture, Uri current)
at Umbraco.Web.Routing.UrlProvider.<>cDisplayClass21_0.0(IMediaUrlProvider provider)
at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext()
at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable1 source, Func2 predicate)
at Umbraco.Web.Routing.UrlProvider.GetMediaUrl(IPublishedContent content, UrlMode mode, String culture, String propertyAlias, Uri current)
at Umbraco.Cloud.Headless.Backoffice.Compose.BackofficeComponent.EditorModelEventManager_OnSendingMediaModel(HttpActionExecutedContext sender, EditorModelEventArgs1 e)
at Umbraco.Web.Editors.EditorModelEventManager.EmitEvent(HttpActionExecutedContext sender, EditorModelEventArgs e)
at Umbraco.Web.WebApi.Filters.OutgoingEditorModelEventAttribute.OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
at System.Web.Http.Filters.ActionFilterAttribute.OnActionExecutedAsync(HttpActionExecutedContext actionExecutedContext, CancellationToken cancellationToken)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Filters.ActionFilterAttribute.
It's an issue we had a while back which is now resolved but I've pasted some cURLs for both image and file media types on the thread .
You're using the Image media type which is also what you should have and given the error you get, it might be worth checking how the file path looks like :)
I meant the local file path like C:\Users\Lindow\Desktop\capybara.png
Maybe the path isn't correct and the file cannot be accessed through it.
You can eventually try to create and upload the file using an HTTP client like Postman to see if that works for you.
If that's not the case then I'll check with one of the guys who made this SDK, as I'm not familiar with them but only with the Heartcore functionality.
Unable to create new media via NodeJS client
Hey there!
I'm trying to create a new media using the nodeJS client.
This is the code I have:
The media itself is created, but it doesn't have a thumbnail and whenever I try to open in, I get the following error:
Has anyone faced this issue? I'm really lost here and don't know what I'm doing wrong :\
Thanks
Hi there
Which file type are you uploading?
As for the blank error, check the log viewer in the settings section for the proper stack trace :)
Hey there Lindow, thanks for the fast reply!
The file type is PNG.
The error in the log viewer does not give much information on what to do... I'll paste it here (pardon the length)
System.ArgumentException: Path must start with a slash. Parameter name: path at Umbraco.Core.UriExtensions.Rewrite(Uri uri, String path) at Umbraco.Web.Routing.DefaultMediaUrlProvider.AssembleUrl(String path, Uri current, UrlMode mode) at Umbraco.Web.Routing.DefaultMediaUrlProvider.GetMediaUrl(UmbracoContext umbracoContext, IPublishedContent content, String propertyAlias, UrlMode mode, String culture, Uri current) at Umbraco.Cloud.StorageProviders.AzureBlob.CdnMediaUrlProvider.GetMediaUrl(UmbracoContext umbracoContext, IPublishedContent content, String propertyAlias, UrlMode mode, String culture, Uri current) at Umbraco.Web.Routing.UrlProvider.<>cDisplayClass21_0.0(IMediaUrlProvider provider) at System.Linq.Enumerable.WhereSelectEnumerableIterator
2.MoveNext() at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable
1 source, Func2 predicate) at Umbraco.Web.Routing.UrlProvider.GetMediaUrl(IPublishedContent content, UrlMode mode, String culture, String propertyAlias, Uri current) at Umbraco.Cloud.Headless.Backoffice.Compose.BackofficeComponent.EditorModelEventManager_OnSendingMediaModel(HttpActionExecutedContext sender, EditorModelEventArgs
1 e) at Umbraco.Web.Editors.EditorModelEventManager.EmitEvent(HttpActionExecutedContext sender, EditorModelEventArgs e) at Umbraco.Web.WebApi.Filters.OutgoingEditorModelEventAttribute.OnActionExecuted(HttpActionExecutedContext actionExecutedContext) at System.Web.Http.Filters.ActionFilterAttribute.OnActionExecutedAsync(HttpActionExecutedContext actionExecutedContext, CancellationToken cancellationToken) --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Filters.ActionFilterAttribute.Okay, what exactly is the value of
path.basename(fileUrl)
? because it needs to be a working path to a file and there seems to be an issue with yours.I have some HTTP calls saved in my Insomnia but I can't get the software to open for some reason, so here's the next best thing - https://github.com/umbraco/Umbraco.Cloud.Issues/issues/539#issue-1126477238
It's an issue we had a while back which is now resolved but I've pasted some cURLs for both image and file media types on the thread .
You're using the Image media type which is also what you should have and given the error you get, it might be worth checking how the file path looks like :)
Thanks again for the fast reply :)
The
path.basename(fileUrl)
returns the name of the file (i.e. "image.png") as per Official Umbraco Headless example.The only difference I have is that the data
umbracoFile
appendend to the FormData is a binary string while in the example is afs.ReadStream
.Maybe I have to save the image locally and upload it using node's file system module..
Oh, yeah, I get that part :)
I meant the local file path like
C:\Users\Lindow\Desktop\capybara.png
Maybe the path isn't correct and the file cannot be accessed through it.
You can eventually try to create and upload the file using an HTTP client like Postman to see if that works for you.
If that's not the case then I'll check with one of the guys who made this SDK, as I'm not familiar with them but only with the Heartcore functionality.
I'll try to save the image locally and then upload it exactly as the official example :)
If, by any change, you could check with any dev from the SDK it would be great! It is missing some documentation as it is :\
I've just tested it by downloading the image and then using the File System module's
createReadStream()
and it was uploaded!It is something with the way I was uploading it.. but I don't know what it is :\
Hi again
Could you create a new issue on the NodeJS tracker https://github.com/umbraco/Umbraco.Headless.Client.NodeJs/issues/new and explain what documentation you're missing?
Also, please mark this thread as resolved if you've figured out your issue. You can do that by clicking the checkmark under your post :)
Will do! Thanks Lindow
Thanks, Pedro :) https://github.com/umbraco/Umbraco.Headless.Client.NodeJs/issues/98
is working on a reply...