Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Morten Leerhøy 11 posts 82 karma points
    Apr 25, 2019 @ 10:18
    Morten Leerhøy
    0

    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

  • Marc Goodson 1024 posts 6755 karma points MVP 4x c-trib
    Apr 27, 2019 @ 11:45
    Marc Goodson
    0

    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:

    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...

    regards

    Marc

  • Morten Leerhøy 11 posts 82 karma points
    Apr 29, 2019 @ 07:13
    Morten Leerhøy
    0

    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

  • Hugo Becerra 10 posts 80 karma points
    Aug 16, 2019 @ 09:57
    Hugo Becerra
    0

    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!

  • Morten Leerhøy 11 posts 82 karma points
    Aug 16, 2019 @ 10:02
    Morten Leerhøy
    1

    Unfortunately not.

  • Hugo Becerra 10 posts 80 karma points
    Aug 16, 2019 @ 10:03
    Hugo Becerra
    0

    Ok, thanks anyway.

Please Sign in or register to post replies

Write your reply to:

Draft