从Web应用程序将文件上传到云 [英] Upload files to the cloud from web application

查看:84
本文介绍了从Web应用程序将文件上传到云的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将文件从HTML 5应用程序(用于台式机/移动设备/平板电脑)(没有服务器端)上传到在线存储中.任何存储都可以,但此时最好使用免费服务.所需的工作流程是:

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:

将文件上传到存储->获取文件的公共URL->使用facebook的API在facebook中共享公共URL.

upload file to a storage -> get file's public URL -> share the public URL in facebook with facebook's API.

我已经了解了facebook部分,但是我需要在某个地方放置文件.我尝试使用box.net 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);
      }
   });
}

在chrome控制台中的产量:

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.

推荐答案

经过一些研究,这里的问题是JS无法与不同于其下载域的域进行交互.

The problem there, after some research, is that JS cannot interact with a domain different from the one it was download from.

这就是为什么您不能将FB JS库下载到您的域,而是每次都从他们的网站加载它的原因.这就是为什么我不能做我在问题中试图做的事情的原因.

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:)

这篇关于从Web应用程序将文件上传到云的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆