Dve*_*vex 6 file-upload react-native
我在react-native中使用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)
}
})
Run Code Online (Sandbox Code Playgroud)
但我收到一个错误:
unexpected response while creating upload, originated from request (response code: 405, response text: Method Not Allowed)
Run Code Online (Sandbox Code Playgroud)
这是正确的方法吗?我有什么错吗?
| 归档时间: |
|
| 查看次数: |
1090 次 |
| 最近记录: |