Upload files to the cloud from web application
I need to upload files from an HTML 5 application (used in desktop/mobile/tablet device)(there's no server side) to an online storage. Any storage would be fine, still, using a free service would be preferred at this point. The needed workflow is开发者_StackOverflow:
upload file to a storage -> get file's public URL -> share the public URL in facebook with facebook's API.
The facebook part I've got it covered but I need somewhere to put my files in. I tried using box.net API but I get error due to the cross-site request being made:
( http://developers.box.net/w/page/12923936/ApiFunction_get_ticket )
function get_ticket(api_key){
$.ajax({
url: 'https://www.box.net/api/1.0/rest?action=get_ticket&api_key=' + api_key,
success: function(response){
console.log(response);
}
});
}
yields in the chrome console:
XMLHttpRequest cannot load https://www.box.net/api/1.0/rest?action=get_ticket&api_key=(my_key). Origin http://localhost:8000 is not allowed by Access-Control-Allow-Origin.
GET https://www.box.net/api/1.0/rest?action=get_ticket&api_key=ynu54ytflrz9fzpdzy5raf1hc1rmed9i undefined (undefined)
Any workaround on this issue will be most welcomed.
The problem there, after some research, is that JS cannot interact with a domain different from the one it was download from.
That's why you cannot download the FB JS library to your domain but instead load it from their website every time. That's also why I'm not able to do what I've tried to do in the question.
Feel free to add up to my explanation if you've got any more details on this issue:)
The error in the console says:
Origin http://localhost:8000 is not allowed by Access-Control-Allow-Origin.
Maybe you could try uploading your application to its future server.
精彩评论