这些图像可以加载在本地ENV,也可以在生产ENV。但是,没有任何理由,暂存环境不能加载这些。
<package id="ImageProcessor" version="2.2.0.0" targetFramework="net45" />
<package id="ImageProcessor.Web" version="4.2.1.0" targetFramework="net45" />
<package id="ImageProcessor.Web.Config" version="2.2.0.0" targetFramework="net45" />
<package id="ImageProcessor.Web.Plugins.AzureBlobCache" version="1.0.0.0" targetFramework="net45" />
<package id="ImageProcessor.Web.PostProcessor" version="1.0.2.0" targetFramework="net45" />
<package id="UmbracoAzureBlobStorageProvider" version="1.0.10.5" targetFramework="net45" />
<package id="WindowsAzure.Storage" version="4.3.0" targetFramework="net45" />我使用的是ImageProcessor,并且域按需要被白化:
<whitelist>
<add url="http://conceptjp.blob.core.windows.net/"/>
<add url="https://az739977.vo.msecnd.net/"/>
</whitelist>https://cjp.local/remote.axd?https://az739977.vo.msecnd.net/media/6883/logo-sparitual.png?quality=70 (工程,本地环境)
2016-10-04 13:31:11.2393 Logging.TheLogger The remote server returned an error: (403) Forbidden. The remote server returned an error: (403) Forbidden. at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.EndExecuteAsync[T](IAsyncResult result)
at Microsoft.WindowsAzure.Storage.Core.Util.AsyncExtensions.<>c__DisplayClass1`1.<CreateCallback>b__0(IAsyncResult ar)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at ImageProcessor.Web.Plugins.AzureBlobCache.AzureBlobCache.<IsNewOrUpdatedAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at ImageProcessor.Web.HttpModules.ImageProcessingModule.<ProcessImageAsync>d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.TaskAsyncHelper.EndTask(IAsyncResult ar)
at System.Web.HttpApplication.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult ar)发布于 2016-10-06 00:58:31
我不知道在这里该说什么。几乎所有的东西都是以一种我不希望也不推荐的方式使用的。
如果您在Azure上使用Umbraco,您应该为您的媒体使用以下插件。
https://github.com/JimBobSquarePants/UmbracoFileSystemProviders.Azure
您正在使用的FileSystemProvider已经过时约一年半了。实际上,它建议在主页上使用上面提到的插件。
新包UmbracoFileSystemProviders.Azure在线!请参阅:https://our.umbraco.org/projects/collaboration/umbracofilesystemprovidersazure/ 我建议您不要这样做,尤其是如果您使用的是Umbraco 7.3或更高版本的话。它解决了很多问题,否则你会在后台办公室。
https://our.umbraco.org/projects/backoffice-extensions/azure-blob-storage-provider
这样做的原因是,原始提供程序有缺陷,如果不完全重写,就无法修复。
在开始进入数据库之前,您必须替换媒体引用,以便从存储的url中删除域。我个人建议从零开始重建你的媒体部分。
GitHub页面上有全面的说明,但我将在这里列出它们。
第一。卸载旧插件,将所有ImageProcessor库更新为最新版本,并安装推荐的FileSystemProvider插件
然后更新~/Config/FileSystemProviders.config,用以下内容替换默认提供程序:
<?xml version="1.0"?>
<FileSystemProviders>
<Provider alias="media" type="Our.Umbraco.FileSystemProviders.Azure.AzureBlobFileSystem, Our.Umbraco.FileSystemProviders.Azure">
<Parameters>
<add key="containerName" value="media" />
<add key="rootUrl" value="http://[myAccountName].blob.core.windows.net/" />
<add key="connectionString" value="DefaultEndpointsProtocol=https;AccountName=[myAccountName];AccountKey=[myAccountKey]"/>
<!--
Optional configuration value determining the maximum number of days to cache items in the browser.
Defaults to 365 days.
-->
<add key="maxDays" value="365" />
</Parameters>
</Provider>
</FileSystemProviders>现在您需要配置CloudImageService以捕获以/media/开头的所有请求。
<?xml version="1.0"?>
<security>
<services>
<service name="LocalFileImageService" type="ImageProcessor.Web.Services.LocalFileImageService, ImageProcessor.Web"/>
<service prefix="media/" name="CloudImageService" type="ImageProcessor.Web.Services.CloudImageService, ImageProcessor.Web">
<settings>
<setting key="Container" value="media"/>
<setting key="MaxBytes" value="8194304"/>
<setting key="Timeout" value="30000"/>
<setting key="Host" value="http://[myAccountName].blob.core.windows.net/media"/>
</settings>
</service>
</services>
确保正确设置了缓存配置。
<caching currentCache="AzureBlobCache">
<caches>
<!-- Disk cache configuration removed for brevity -->
<cache name="AzureBlobCache" type="ImageProcessor.Web.Plugins.AzureBlobCache.AzureBlobCache, ImageProcessor.Web.Plugins.AzureBlobCache" maxDays="365">
<settings>
<!-- The Account, Container and CDN details -->
<setting key="CachedStorageAccount" value="DefaultEndpointsProtocol=https;AccountName=[CacheAccountName];AccountKey=[CacheAccountKey]"/>
<setting key="CachedBlobContainer" value="cache"/>
<!-- Whether to add the container name to the CDN url. Newer Azure formats require false. -->
<setting key="UseCachedContainerInUrl" value="true"/>
<!-- Full CDN root url e.g http://123456.vo.msecnd.net/ -->
<setting key="CachedCDNRoot" value="[CdnRootUrl]"/>
<!-- Optional setting for a timeout limit in milliseconds when attempting to communicate with the CDN url. -->
<setting key="CachedCDNTimeout" value="1000"/>
<!--
Optional settings for better identifcation of source images if stored in
Azure blob storage.
-->
<setting key="SourceStorageAccount" value=""/>
<setting key="SourceBlobContainer" value=""/>
<!--
Optional settings facilitate streaming of the blob resource directly instead of a redirect. This is beneficial
for CDN purposes but caution should be taken if not used with a CDN as it will add quite a bit of overhead
to the site.
-->
<setting key="StreamCachedImage" value="false"/>
</settings>
</cache>
</caches>
</caching>现在应该使用根相对/media/路径创建图像请求,内置的虚拟路径提供程序将拦截并相应处理该路径。
例如/media/1046/car-small.jpg?width=500&height=500&mode=boxpad&bgcolor=hotpink
https://stackoverflow.com/questions/39878104
复制相似问题