Closed halegreen closed 5 years ago
你是指你打印的result中没有x-oss-request-id字段?(ps:我试的结果res.headers里有x-oss-request-id字段)
@Ari1c 不是result,没有打印出result,是oss sdk里面报的错,是sdk解析response的时候没有x-oss-request-id字段
你有在里面的example跑一下吗
@Ari1c 这个sdk只有在chrome端才能用吗,我的client是支付宝小程序
也不是啊,高版本浏览器都是可以的啊,小程序暂时只支持直传,https://help.aliyun.com/document_detail/92883.html?spm=a2c4g.11186623.6.1269.354460casu6Ll9
你在控制台check一下跨域配置里headers有配置x-oss-request-id字段
@Ari1c 跨域设置加了的,还是不行。 另外小程序暂时只支持直传的例子:https://help.aliyun.com/document_detail/92883.html?spm=a2c4g.11186623.6.1269.354460casu6Ll9 适用于支付宝小程序么?
my.chooseImage({
chooseImage: 1,
success: res => {
const path = res.apFilePaths[0];
console.log(path)
var key = 'image.jpg'
my.uploadFile({
url: 'https://ocr-image-bucket.oss-cn-shanghai.aliyuncs.com', //ocr image bucket host
fileType: 'image',
fileName: key,
filePath: path,
formData: {
name: path,
key: '${filename}',
policy: '<my-policy>',
OSSAccessKeyId: '<my-OSSAccessKeyId>',
success_action_status: '200',
signature: '<my-signature>'
},
success: (res) => {
my.alert({ content: 'success info: ' + res.data });
},
});
});
我这边也试了下支付宝小程序直传这个方式,oss返回400: 我明明只选择了一个图片上传,并没有多个,不知道啥问题?
<?xml version="1.0" encoding="UTF-8"?>
<Error>
<Code>IncorrectNumberOfFilesInPOSTRequest</Code>
<Message>POST requires exactly one file upload per request.</Message>
<RequestId>5CF091D883464DAC560BBF9B</RequestId>
<HostId>ocr-image-bucket.oss-cn-shanghai.aliyuncs.com</HostId>
</Error>
在云函数里面用 putStream 也遇到了一样的报错,执行环境是阿里云的香港 node8 云函数
@ZoeShaw101 小程序直传你要保证你的bucket是读写权限的(但不建议),不是读写权限的话是要设置policy,ak,signature的
@ZoeShaw101 https://help.aliyun.com/document_detail/127260.html?spm=a2c4g.11186623.6.1487.24483ccc3q7qLh 这是支付宝小程序的情况
@richard1122 你能描述具体点吗,也是在小程序中使用我们的sdk是吗(小程序目前支持直传)
@Ari1c 是在云函数里直接 put stream 时候传一个 node 的 buffer
@richard1122 你的bucket有设置跨域规则(x-oss-request-id字段),或者把报错信息解一下图
我也遇到同样的错误,node端 流式上传文件,报这个错误
如果是读取本地文件上传 则正常
进去调试 ,里面报
到现在任然在报错
使用sdk遇到这个问题,版本6.1.1,似乎是返回的response没有x-oss-request-id这个字段?求解答