我尝试使用api从浏览器直接将视频上传到vimeo帐户,创建了视频详细信息,但文件似乎已损坏/没有上传。这是我的示例代码。
var file = $(this).prop("files")[0];
var formData = new FormData();
formData.append("file_data", file);
$.ajax({
url: "https://api.vimeo.com/me/videos/",
type: "post",
data: formData,
headers: {
"Authorization": "Bearer -----",
},
processData: false,
mimeType: "multipart/form-data",
contentType: false,
}).done(function (response) {
// Do something
}).complete(function (response) {
// Do something
}).fail(function (e) {
// Do something
});
vimeo视频列表显示空白缩略图 enter image description here
答案 0 :(得分:0)
尝试这段代码。我在这里做了一些更改:
var file = $(this).prop("files")[0];
var formData = new FormData();
formData.append("file_data", file);
$.ajax("https://api.vimeo.com/me/videos/", {
type: "POST",
headers: {
"Authorization": "Bearer -----",
},
data: formData,
contentType: "multipart/form-data", // changed this
dataType: "json",
crossDomain: true // for CORS policy error
}).done((response) => {
// Do something
}).fail((error) => {
// Do something
}).complete(() => {
// Do something
});
我已经追赶contentType
,并删除了mimeType
。我还删除了不必要的processData
字段。