英文:
Preview of my uploaded assets to Private Azure blob storage is not showing in strapi dashboard
问题
上传到私人 Azure Blob 存储后,我的上传资产的预览不显示在 Strapi 仪表板中。我正在使用我的存储访问密钥来为 Strapi 提供权限。我能够通过 Strapi 仪表板上传和删除文件,但无法预览和下载。任何快速帮助将不胜感激。已经为此挣扎了几天。
以下是我在 Strapi 代码的 middleware.js 中使用的代码:
name: "strapi::security",
config: {
contentSecurityPolicy: {
useDefaults: true,
directives: {
"connect-src": ["'self'", "https:"],
"img-src": [
"'self'",
"data:",
"blob:",
"dl.airtable.com",
"https://market-assets.strapi.io",
"https://*.blob.core.windows.net",
"https://*.blob.core.windows.net/my_bucket_name",
],
"media-src": [
"'self'",
"data:",
"blob:",
"dl.airtable.com",
"https://*.blob.core.windows.net",
"https://*.blob.core.windows.net/my_bucket_name",
],
upgradeInsecureRequests: null,
},
},
},
},```
以下是我在配置中为 Azure 给予 Strapi 权限的部分:
```upload: {
config: {
provider: 'strapi-provider-upload-azure-storage',
providerOptions: {
account: env('STORAGE_ACCOUNT'),
accountKey: env('STORAGE_ACCOUNT_KEY'),
serviceBaseURL: env('STORAGE_URL'),
containerName: env('STORAGE_CONTAINER_NAME'),
defaultPath: 'assets',
maxConcurrent: 100,
expiresIn:3600,
}
}
},```
[以下是您可以找到图像的链接][1]
[1]: https://i.stack.imgur.com/xhZrN.png
<details>
<summary>英文:</summary>
[enter image description here][1]The preview of my uploaded assets is not showing in Strapi dashboard after uploading the file to my Private Azure blob storage. I am using my storage access key to provide permission to Strapi. I am able to upload and delete the file through the Strapi dashboard but the preview and download are not available. Any quick help will be much appreciated. Struggling with this for a couple of days.
Below is the code I am using in middleware.js of Strapi code
```{
name: "strapi::security",
config: {
contentSecurityPolicy: {
useDefaults: true,
directives: {
"connect-src": ["'self'", "https:"],
"img-src": [
"'self'",
"data:",
"blob:",
"dl.airtable.com",
"https://market-assets.strapi.io",
"https://*.blob.core.windows.net",
"https://*.blob.core.windows.net/my_bucket_name",
],
"media-src": [
"'self'",
"data:",
"blob:",
"dl.airtable.com",
"https://*.blob.core.windows.net",
"https://*.blob.core.windows.net/my_bucket_name",
],
upgradeInsecureRequests: null,
},
},
},
},```
Below is the configuration where I am giving permission access to Strapi for Azure
```upload: {
config: {
provider: 'strapi-provider-upload-azure-storage',
providerOptions: {
account: env('STORAGE_ACCOUNT'),
accountKey: env('STORAGE_ACCOUNT_KEY'),
serviceBaseURL: env('STORAGE_URL'),
containerName: env('STORAGE_CONTAINER_NAME'),
defaultPath: 'assets',
maxConcurrent: 100,
expiresIn:3600,
}
}
},```
[Below is the link where you can find the image][1]
[1]: https://i.stack.imgur.com/xhZrN.png
</details>
# 答案1
**得分**: 0
```javascript
account: env("STORAGE_ACCOUNT"),
accountKey: env("STORAGE_ACCOUNT_KEY"),
serviceBaseURL: env("STORAGE_URL"), // optional
containerName: env("STORAGE_CONTAINER_NAME"),
defaultPath: "assets",
cdnBaseURL: env("STORAGE_CDN_URL")
"media-src": [
"'self'",
"data:",
"blob:",
"dl.airtable.com",
/**
* 注意:如果使用STORAGE_URL,请用process.env.STORAGE_URL替换`https://${process.env.STORAGE_ACCOUNT}.blob.core.windows.net`
* 如果使用CDN URL,请确保在CSP头部包含该URL process.env.STORAGE_CDN_URL
*/
`https://${process.env.STORAGE_ACCOUNT}.blob.core.windows.net`,
],
upgradeInsecureRequests: null,
- 确保在应用程序的相应路径中创建文件夹。
英文:
>Followed this MSDoc for Srapi.
Code:
account: env("STORAGE_ACCOUNT"),
accountKey: env("STORAGE_ACCOUNT_KEY"),
serviceBaseURL: env("STORAGE_URL"), // optional
containerName: env("STORAGE_CONTAINER_NAME"),
defaultPath: "assets",
cdnBaseURL: env("STORAGE_CDN_URL")
"media-src": [
"'self'",
"data:",
"blob:",
"dl.airtable.com",
/**
* Note: If using a STORAGE_URL replace `https://${process.env.STORAGE_ACCOUNT}.blob.core.windows.net` w/ process.env.STORAGE_URL
* If using a CDN URL make sure to include that url in the CSP headers process.env.STORAGE_CDN_URL
*/
`https://${process.env.STORAGE_ACCOUNT}.blob.core.windows.net`,
],
upgradeInsecureRequests: null,
- Make sure to please the folder in the respective path of the app.
Output :
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论