From 671a18a018d609e70268a03969206535796c1eb0 Mon Sep 17 00:00:00 2001 From: VK <370725567@qq.com> Date: Thu, 27 Jun 2024 11:56:07 +0800 Subject: [PATCH] update: ext-storage/dev.md --- docs/ext-storage/dev.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/docs/ext-storage/dev.md b/docs/ext-storage/dev.md index 7d479d2..e14b5e6 100644 --- a/docs/ext-storage/dev.md +++ b/docs/ext-storage/dev.md @@ -156,6 +156,32 @@ uni.chooseImage({ **云端代码** +将网络图片转为Buffer上传到扩展存储 + +```js +const extStorageManager = uniCloud.getExtStorageManager({ + provider: "qiniu", + domain: "example.com", // 域名地址 +}); +let imageBuffer = await uniCloud.request({ + url: "https://www.xxx.com/a.jpg", + method: "GET", + responseType: "buffer", + header: { + "cache-control": "no-cache", + } +}); + +let res = await extStorageManager.uploadFile({ + cloudPath: `${Date.now()}.png`, // 云端文件名,不填则自动生成 + fileContent: imageBuffer.data, // 要上传的文件内容 + allowUpdate: false, // 是否允许覆盖 +}); +console.log('uploadFile: ', res); +``` + +将base64转为Buffer上传到扩展存储 + ```js const extStorageManager = uniCloud.getExtStorageManager({ provider: "qiniu", -- GitLab