Phi*_*ock 4 browser object-storage minio
我正在将 svg 文件上传到本地 minio 服务器(在 docker 中运行)。
const uploadedFile = await client.putObject(bucketName, filename, readStream);
Run Code Online (Sandbox Code Playgroud)
然后我生成一个公共 URL,例如http://localhost:9000/link-identifiers/example.svg
,我可以从那里公开下载文件
如果我想在浏览器中显示它<img src={picUrl}>
,则图像根本不会渲染。
我在浏览器中得到这些响应标头:
HTTP/1.1 200 OK
Accept-Ranges: bytes
Content-Length: 124775
Content-Security-Policy: block-all-mixed-content
Content-Type: application/octet-stream
ETag: "109be6a37b9091e50651b3cbbe6bed3a"
Last-Modified: Wed, 02 Sep 2020 06:44:28 GMT
Server: MinIO/RELEASE.2020-08-07T01-23-07Z
Vary: Origin
X-Amz-Request-Id: 1630E4E87DF71408
X-Xss-Protection: 1; mode=block
Date: Wed, 02 Sep 2020 06:52:34 GMT
Run Code Online (Sandbox Code Playgroud)
为了使图像渲染,我需要对 minio 服务器进行任何额外的配置吗?如果我能够下载它们并且它们非常好(在查看它们时),它们是否也应该能够在浏览器中呈现?
当前存储桶的权限设置为public
:
mc policy set public myminio/link-identifiers
Run Code Online (Sandbox Code Playgroud)
小智 5
该putObject
函数接受一个可选metadata
参数。
const metadata = {
'Content-type': 'image',
};
Run Code Online (Sandbox Code Playgroud)
将其作为参数传递给函数以便能够渲染图像。