Hi all,
I'm using Umbraco 8 in load balancing.
I'm programmatically uploading images using mediaService. Invoking Save method I pass true to raiseEvents.
The issue is that when I go to Umbraco backend it seems that the image has not been published because there is no image link in Info tab. I have tried to inject ICacheRefresher but the application crashes.
My guess is that you are doing all the right things for creating the database entry for your new Media Item, but perhaps not setting the umbracoFile property on this new Media object, to be a stream containing your file content...
.. this is easiest to do if you have a HttpPostedFiles collection (eg you have a form that has an upload control that posts the file to your controller, and you can just use this from the posted values)
... but if you have the file on disk, eg you are doing some kind of one off import, then you have to read the file into a filestream...
The only difference I can see (and the sample might be out of date) is not using CreateMediaWithIdentity (this persists to the database immediately whereas CreateMedia, waits til you call save)
Not sure it will make a difference in your case.
Does you code work locally, eg is it just a load balanced scenario where it doesn't work?
And if so, do you see the image on some instance but not others?
And are you using BlobStorage as your FileSystemProviders (so the instances all share the same media location) or are you syncing files between instances.
thanks!
We are trying with your suggestion, but we have to wait because the issue does not occur in a systematic way in the production environment and locally works fine.
Is there a way to refresh MemoryCache?
Issue uploading image in load balancing
Hi all, I'm using Umbraco 8 in load balancing. I'm programmatically uploading images using mediaService. Invoking Save method I pass true to raiseEvents. The issue is that when I go to Umbraco backend it seems that the image has not been published because there is no image link in Info tab. I have tried to inject ICacheRefresher but the application crashes.
Thank you!
Hi Francesco
Can you share your code?
My guess is that you are doing all the right things for creating the database entry for your new Media Item, but perhaps not setting the umbracoFile property on this new Media object, to be a stream containing your file content...
.. this is easiest to do if you have a HttpPostedFiles collection (eg you have a form that has an upload control that posts the file to your controller, and you can just use this from the posted values)
... but if you have the file on disk, eg you are doing some kind of one off import, then you have to read the file into a filestream...
https://our.umbraco.com/Documentation/Reference/Management/Services/MediaService/Index-v8#creating-a-new-media-item-from-a-stream
Anyway that's the hunch, you might already be doing that...
regards
marc
Hi Marc, thanks for the reply! Here is my code
I think it is all ok thank you
F
Hi Francesco
I know there is this example in the docs:
https://our.umbraco.com/Documentation/Reference/Management/Services/MediaService/Index-v8#creating-a-new-media-item-from-a-stream
The only difference I can see (and the sample might be out of date) is not using CreateMediaWithIdentity (this persists to the database immediately whereas CreateMedia, waits til you call save)
Not sure it will make a difference in your case.
Does you code work locally, eg is it just a load balanced scenario where it doesn't work?
And if so, do you see the image on some instance but not others?
And are you using BlobStorage as your FileSystemProviders (so the instances all share the same media location) or are you syncing files between instances.
regards
marc
thanks! We are trying with your suggestion, but we have to wait because the issue does not occur in a systematic way in the production environment and locally works fine. Is there a way to refresh MemoryCache?
thank you
is working on a reply...