uniapp使用uni.uploadFile上传图片,通过后端返回的授权链接,put文件到阿里云服务器
希望有调用成功过的人士帮我解答,谢谢了
试试这个https://blog.csdn.net/qq_42543244/article/details/123500765
uniapp:上传图片文件到阿里云oss
如有帮助,望采纳
https://blog.csdn.net/qq_42543244/article/details/123500765
如果你的后端已经返回了授权链接,那么在 uniapp 中可以使用 uni.uploadFile API 来上传图片到阿里云服务器。
实现步骤如下:
在 uniapp 中使用 uni.chooseImage API 选择要上传的图片。
使用 uni.uploadFile API 将选择的图片上传到阿里云服务器。需要提供阿里云服务器的授权链接作为参数。
阿里云服务器接收到图片后,将返回一个响应,表示图片上传成功。
下面是 uniapp 中使用 uni.uploadFile API 上传图片的示例代码:
// 选择要上传的图片
uni.chooseImage({
success: function(res) {
var tempFilePaths = res.tempFilePaths
// 使用 uni.uploadFile API 上传图片
uni.uploadFile({
url: '授权链接', // 授权链接
filePath: tempFilePaths