You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I’m currently experimenting ImageSharp and trying to use an S3-compatible storage solution as both my image provider and cache. I’ve run into something that I’m hoping someone can shed some light on.
What’s happening:
Local Provider First:
I’m using the ABP.IO framework, so the upload system is already handled by it.
Initially, I configured my setup with a local image provider. I uploaded an image, and everything worked fine—the image got processed and cached (just a simple resize) locally.
Switching to S3 Provider:
Next, I switched my configuration over to use an S3-compatible provider. When I did that, the image that was originally uploaded locally got cached and showed up in S3 as expected, which was awesome.
Direct S3 Upload:
Here’s where it gets confusing: When I upload a new image directly to the S3 provider, the image is successfully stored in S3, but it doesn’t seem to be cached. On my page, it simply serves the original image from S3, even though I expected it to be cached as well.
Is this behavior expected? Should images uploaded directly to S3 also trigger the caching mechanism, or does caching only work with local images?
Does anyone have advice on ensuring that images uploaded directly to S3 are properly cached? Am I missing any configuration or steps?
privatevoidConfigureImageSharpWeb(IServiceCollectionservices,IConfigurationconfiguration){varimageSharpBuilder=services.AddImageSharp();if(MediaConstant.DefaultImageProvider==ImageProvider.Local){imageSharpBuilder.Configure<PhysicalFileSystemCacheOptions>(options =>{options.CacheFolder="cache";});}elseif(MediaConstant.DefaultImageProvider==ImageProvider.S3){imageSharpBuilder.Configure<AWSS3StorageImageProviderOptions>(options =>{options.S3Buckets.Add(newAWSS3BucketClientOptions{Endpoint=configuration["S3Provider:ServiceUrl"],BucketName=configuration["S3Provider:BucketName"],AccessKey=configuration["S3Provider:AccessKeyId"],AccessSecret=configuration["S3Provider:SecretAccessKey"],// Region = configuration["S3Provider:Region"], // Not needed});}).AddProvider<AWSS3StorageImageProvider>().Configure<AWSS3StorageCacheOptions>(options =>{options.Endpoint=configuration["S3Provider:ServiceUrl"];options.BucketName=configuration["S3Provider:BucketName"];options.AccessKey=configuration["S3Provider:AccessKeyId"];options.AccessSecret=configuration["S3Provider:SecretAccessKey"];// options.Region = configuration["S3Provider:Region"], // Not neededoptions.CacheFolder="cache";}).SetCache<AWSS3StorageCache>();}}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi,
I’m currently experimenting ImageSharp and trying to use an S3-compatible storage solution as both my image provider and cache. I’ve run into something that I’m hoping someone can shed some light on.
What’s happening:
Local Provider First:
I’m using the ABP.IO framework, so the upload system is already handled by it.
Initially, I configured my setup with a local image provider. I uploaded an image, and everything worked fine—the image got processed and cached (just a simple resize) locally.
Switching to S3 Provider:
Next, I switched my configuration over to use an S3-compatible provider. When I did that, the image that was originally uploaded locally got cached and showed up in S3 as expected, which was awesome.
Direct S3 Upload:
Here’s where it gets confusing: When I upload a new image directly to the S3 provider, the image is successfully stored in S3, but it doesn’t seem to be cached. On my page, it simply serves the original image from S3, even though I expected it to be cached as well.
Is this behavior expected? Should images uploaded directly to S3 also trigger the caching mechanism, or does caching only work with local images?
Does anyone have advice on ensuring that images uploaded directly to S3 are properly cached? Am I missing any configuration or steps?
Beta Was this translation helpful? Give feedback.
All reactions