I am trying to upload a video to Vimeo via Ajax but I am running into CORS problems with Firefox.
Here is the code I am using. It is only at the last stage of posting the file does CORS protection prevent the upload.
I have checked the headers and Cross Origin is set correctly.
$.ajax({
url:'https://api.vimeo.com/me',
crossDomain:true,
headers:{Authorization: 'bearer ',Accept:'application/vnd.vimeo.*+json;version=3.2'},
error:function(){
videoError('Couldn\'t get a quota');
},
success:function(uploadQuota){
if(uploadQuota.upload_quota.space.free > 0 && (uploadQuota.upload_quota.quota.sd == true || uploadQuota.upload_quota.quota.hd == true)){
//Get Upload Ticket
$.ajax({
url:'https://api.vimeo.com/me/videos',
data:{type:'POST'},
type:'POST',
dataType:'json',
crossDomain:true,
headers:{Authorization: 'bearer ',Accept:'application/vnd.vimeo.*+json;version=3.2'},
error:function(){
videoError('Couldn\'t get a ticket');
},
success:function(uploadTicket){
if(uploadTicket.ticket_id != ''){
//Upload File
var videoData = new FormData();
$.each($('#video_upload')[0].files, function(i, file) {
videoData.append('file_data', file);
});
$.ajax({
url:uploadTicket.upload_link_secure,
type:'POST',
headers:{Authorization: 'bearer ',Accept:'application/vnd.vimeo.*+json;version=3.2'},
data: videoData,
cache: false,
contentType: 'multipart/form-data',
processData: false,
crossDomain:true,
//dataType:'jsonp',
error:function(){
videoError('Error uploading video. Please contact FDN with the ticket id:'+uploadTicket.ticket_id);
},
success:function(uploadData,status){
//Copy id to text box
}
});
} else {
//If none, process error
}
}
});
} else {
//If none, process error
}
}
});
Is there anything obvious that I have missed or can try?