我在使用反复原生的tus-js-client将视频上传到vimeo时遇到问题。
我尝试将blob文件上传到我手机中的视频vimeo。
URI是this.state.uri
,是我视频的文件路径,例如:file:///data/user/Camera/e520ecbb-e226-434c-8c8d-305621622645.mp4
这是我的代码:
var fileAsString = await FileSystem.readAsStringAsync(this.state.uri)
var file = new File([fileAsString], "video.mp4");
var upload = new tus.Upload(file, {
endpoint: this.state.vimeoUploadLink,
retryDelays: [0, 1000, 3000, 5000],
metadata: {
filename: "video.mp4",
filetype: "video/mp4"
},
onError: function(error) {
console.log("Failed because: " + error)
},
onProgress: function(bytesUploaded, bytesTotal) {
var percentage = (bytesUploaded / bytesTotal * 100).toFixed(2)
console.log(bytesUploaded, bytesTotal, percentage + "%")
},
onSuccess: function() {
console.log("Download %s from %s", upload.file.name, upload.url)
}
})
但我收到了一个错误:
unexpected response while creating upload, originated from request (response code: 405, response text: Method Not Allowed)
这是正确的方法吗?我错了什么?