I've created a custom composer like this:
public void Compose(Composition composition)
{
var rootPath = "c:\mylocalpath";
var rootUrl = "/MyMediaPath";
composition.SetMediaFileSystem(() => new PhysicalFileSystem(rootPath, rootUrl));
}
and I can upload images that are put in the right directory as they should, but I can't view them on the site and there are no thumbnails. ImageProcessor throws this error: ImageProcessor.Common.Exceptions.ImageProcessingException: ProcessImageAsync 610 : No image exists at C:\MyCustomPath\MyMediaPath\a24dkxbl\image.png - it seems like ImageProcessor doesn't pick up the new physical path.
You'll see the LocalImageFileService (configured in /config/imageprocessor/security.config)
checks to see if the file exists before working any image processor magic:
public virtual async Task<byte[]> GetImage(object id)
{
string path = id.ToString();
byte[] buffer;
// Check to see if the file exists.
if (!File.Exists(path))
{
throw new HttpException((int)HttpStatusCode.NotFound, $"No image exists at {path}");
}
and you can see that the error you are seeing is thrown, after the File.Exists(path) check.
So assuming your error message contains the correct path, why would the .net framework say the file doesn't exist at the location? there could be a number of factors but usually it is 'file permissions' based... temporarily granting full permissions to the folder and file here would at least show if this were the case...
The problem is that the path defined in my composer is not picked up - ImageProcessor assumes that the rootUrl is also the correct path. If my example was working, the image would physically be in c:\mylocalpath (unless there is asomething I've missed completely) - permissions on the image folder are as they should be.
Could you find any solution? Because I'm trying to set a different media folder with Composition but is not working. I tried using networks path or local paths.
PhysicalFileSystem & ImageProcessor
Hi,
I've created a custom composer like this: public void Compose(Composition composition) { var rootPath = "c:\mylocalpath"; var rootUrl = "/MyMediaPath"; composition.SetMediaFileSystem(() => new PhysicalFileSystem(rootPath, rootUrl)); }
and I can upload images that are put in the right directory as they should, but I can't view them on the site and there are no thumbnails. ImageProcessor throws this error: ImageProcessor.Common.Exceptions.ImageProcessingException: ProcessImageAsync 610 : No image exists at C:\MyCustomPath\MyMediaPath\a24dkxbl\image.png - it seems like ImageProcessor doesn't pick up the new physical path.
anyone else have this problem?
Regards Morten
Hi Morten
Although because Image Processor reports the problem as
No image exists at C:\MyCustomPath\MyMediaPath\a24dkxbl\image.png
that does sort of suggest it's getting the correct information as to where the file is stored (it is there right?)
If you look at the source of Image Processor: (taking a moment to thank James M South for his work!)
https://github.com/JimBobSquarePants/ImageProcessor/blob/58e18acd42de65b02421a85dee5361c4d74ac2ff/src/ImageProcessor.Web/Services/LocalFileImageService.cs#L71
You'll see the LocalImageFileService (configured in /config/imageprocessor/security.config)
checks to see if the file exists before working any image processor magic:
and you can see that the error you are seeing is thrown, after the File.Exists(path) check.
So assuming your error message contains the correct path, why would the .net framework say the file doesn't exist at the location? there could be a number of factors but usually it is 'file permissions' based... temporarily granting full permissions to the folder and file here would at least show if this were the case...
regards
Marc
Hey Marc,
The problem is that the path defined in my composer is not picked up - ImageProcessor assumes that the rootUrl is also the correct path. If my example was working, the image would physically be in c:\mylocalpath (unless there is asomething I've missed completely) - permissions on the image folder are as they should be.
Thanks for taking to time to look into this!
Regards Morten
Hi Morten,
Could you find any solution? Because I'm trying to set a different media folder with Composition but is not working. I tried using networks path or local paths.
Thanks!
Unfortunately not.
Ok, thanks anyway.
is working on a reply...