Amazon web services 如何确定S3预签名URL中的上载是否成功完成?
使用S3,我可以生成一个预先签名的URL来上传文件,但我无法从另一个资源中确定:Amazon web services 如何确定S3预签名URL中的上载是否成功完成?,amazon-web-services,amazon-s3,Amazon Web Services,Amazon S3,使用S3,我可以生成一个预先签名的URL来上传文件,但我无法从另一个资源中确定: 上载是否成功完成 另一个上传正在进行中 我是在Expo的FileSystem.uploadAsync的背景下问这个问题的,根据后台上传的文档 这是我上传的代码片段 const startResult = await this.webClient.post("/v3/upload/start", { category: meta.category, c
FileSystem.uploadAsync
的背景下问这个问题的,根据后台上传的文档
这是我上传的代码片段
const startResult = await this.webClient.post("/v3/upload/start", {
category: meta.category,
contentType: meta.contentType,
contentMd5Hash: fileInfo.md5,
contentLength: fileInfo.size,
});
if (startResult.status !== 200) {
throw new Error(
`start result got ${startResult.status} expecting 200. ${startResult.data}`
);
}
const {
presignedUploadUrl,
contentMd5,
completionToken,
} = startResult.data;
const result = await FileSystem.uploadAsync(
presignedUploadUrl,
fileInfo.uri,
{
headers: {
"Content-MD5": contentMd5 as string,
"Content-Type": meta.contentType,
},
httpMethod: "PUT",
}
);
// I need to do this to indicate that the upload was completed
// All this tells the backend that it is done, but there's no other
// proof that it was done.
const completeResult = await this.webClient.post("/v3/upload/complete", {
completionToken,
presignedUploadUrl,
});
const { artifactId } = completeResult.data;
console.log(artifactId);
当你说Expo的
FileSystem.uploadAsync
时,你使用的是什么?它返回一个。那么,您是否尝试过检查HTTP状态并比较它是尽快返回还是在上传成功后返回?我仍在尝试了解它是如何工作的,但我还没有实现它。我只是通过邮递员进行测试。你能提供你已经尝试过的代码实现吗?这可以提供一些可以介绍的信息。