ElijahGlover / Umbraco-S3-Provider

Amazon Web Services S3 IFileSystem provider for Umbraco
46 stars 34 forks source link

Images not loading on Umbraco 7.3.x? #3

Closed SleeperSmith closed 8 years ago

SleeperSmith commented 8 years ago

It seems it's having issue on Umbraco 7.3.x? If the media file uploaded is NOT an image, it works fine however, when media file is an image, the provider was never hit?

Any idea?

ElijahGlover commented 8 years ago

I havent tested with 7.3.x. can you paste in your config?

SleeperSmith commented 8 years ago

Web.config

  <location path="media">
    <system.webServer>  
      <handlers>  
        <remove name="StaticFileHandler" />  
        <add name="StaticFileHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.StaticFileHandler" />  
      </handlers>  
    </system.webServer>  
  </location>  
  <umbracoConfiguration>  
    <FileSystemProviders configSource="config\FileSystemProviders.s3.config" xdt:Transform="Replace" />  
  </umbracoConfiguration>  

FileSystemProviders.s3.config

<?xml version="1.0"?>
<FileSystemProviders>
  <Provider alias="media" type="Umbraco.Storage.S3.BucketFileSystem, Umbraco.Storage.S3">
    <Parameters>
      <!-- S3 Bucket Name - Used For Making API Requests -->
      <add key="bucketName" value="test-bucket" />
      <!-- S3 Bucket Hostname - Used For Storage In Umbraco's Database (Can be blank if using the bundled file provider) -->
      <add key="bucketHostName" value="" />
      <!-- S3 Object Key Prefix -->
      <add key="bucketKeyPrefix" value="media" />
      <!-- AWS Region Endpoint (us-east-1/us-west-1/ap-southeast-2) -->
      <add key="region" value="ap-southeast-2" />
    </Parameters>
  </Provider>
</FileSystemProviders>
    public class MvcApplication : UmbracoApplication 
    {
        private readonly ILog _logger = LogManager.GetLogger(typeof(MvcApplication));
        private BackgroundJobServer _backgroundJobServer;

        protected override void OnApplicationStarted(object sender, EventArgs e)
        {
            log4net.Config.XmlConfigurator.Configure();
            base.OnApplicationStarted(sender, e);

            var mediaPath = ConfigurationManager.AppSettings["MediaPath"];
            if (!string.IsNullOrWhiteSpace(mediaPath))
            {
                Umbraco.Storage.S3.FileSystemVirtualPathProvider.ConfigureMedia(mediaPath);
            }

            Application_Start();
            _logger.Info("Application Started");
        }

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            //WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            //RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            AutoMapperConfig.Configure();
        }

        protected new void Application_End(object sender, EventArgs e)
        {
            if (_backgroundJobServer != null)
                _backgroundJobServer.Dispose();
            base.Application_End(sender, e);
        }

    }
SleeperSmith commented 8 years ago

Found the problem. ImageProcessor handler just doesn't work with VPP.

Seems like Umbraco 7.2.x just pass media url straight through to the configured VPP while 7.3.x pass all media url request to the image processor with or without query string?

SleeperSmith commented 8 years ago

@ElijahGlover , just wondering if there's a recommended approach to fix this problem? Do you plan on looking into this issue? (this seems more a problem from the Image Processor handler than the s3 provider...)

ElijahGlover commented 8 years ago

@SleeperSmith recommended approch to resolve is to use Image Processor Remote Files feature listed in the docs. http://imageprocessor.org/imageprocessor-web/imageprocessingmodule/ This workaround will only resolve any images you have embeded locally in html.

When I orignally created this plugin the backoffice would generate thumbnails when uploading the image. That changed early v7. I'm have not looked under the hood of the editor/media services. Please let me know if you have ideas to resolve this issue.

@James_M_South on twitter might have some ideas.

JimBobSquarePants commented 8 years ago

Hi @SleeperSmith @ElijahGlover

ImageProcessor.Web should work fine with the VPP, you need to make sure that you have enabled the CloudImageService for it to intercept image requests though.

Check out the documentation at my Azure FileSystem implementation. https://github.com/JimBobSquarePants/UmbracoFileSystemProviders.Azure#combining-with-imageprocessor.

Set the Host property to

<setting key="Host" value="http://[YOUR_BUCKET_PUBLIC_URL]/media/"/>

And ImageProcessor.Web should correctly intercept and serve any images with the path beginning with /media/

On the note of ImageProcessor.Web capturing all image requests, if you update the installed version via Nuget it will intercept only requests with a querystring. I made intercepting all images optional as it was causing problem in some environments.

Hope that helps

James

SleeperSmith commented 8 years ago

@JimBobSquarePants O_O Did you search for all issue on github with image processor in it repeatedly like once every few minutes or you just happen to crash the party with impeccable timing.

Anyway, much thanks, I'll give this a shot. We have servers on both AWS and Azure so this will be very handy.

JimBobSquarePants commented 8 years ago

:smile: Nah... @ElijahGlover grabbed me on Twitter, Supposed to be having a night off but I couldn't help myself to get involved between watching old movies and stuffing my face with M&M's.

Good luck, any issues and I'll do my best to help.

ElijahGlover commented 8 years ago

I've documented changes required to make backoffice work with ImageProcessor, along with a bug fix released as part of 1.0.23.