简体   繁体   English

从客户端JavaScript将Blob上传到保管箱

[英]Upload blob to dropbox from client-side javascript

I have an app that runs in the client browser and doesn't have any server side (http/js is served, but nothing posts to the server). 我有一个在客户端浏览器中运行的应用程序,并且没有任何服务器端(提供了http / js,但没有任何内容发布到服务器)。 the app is redeployed on many servers (iis, apache, nginx, sometimes localhost, sometimes on an intranet) and are served using http (not https). 该应用程序已在许多服务器(iis,apache,nginx,有时是localhost,有时是Intranet)上重新部署,并使用http(而非https)提供服务。 My app generates files such as zip files and pdf's in the clients browser as blobs BEFORE I want to save, so having them navigate away on the same page then back to the app defeats the purpose; 在我要保存之前,我的应用程序在客户端浏览器中会以blob的形式生成诸如zip文件和pdf之类的文件,因此让它们在同一页面上导航然后返回到该应用程序会失败。 and I can't post the generated data to dropbox anymore, since they have to start over... I want to be able to send these blobs directly to files in the end users dropbox (and later google drive). 而且我无法再将生成的数据发布到保管箱,因为它们必须重新开始...我希望能够将这些Blob直接发送到最终用户保管箱(以及后来的Google驱动器)中的文件。

https://www.dropbox.com/developers-v1/dropins/saver performs exactly as I would like. https://www.dropbox.com/developers-v1/dropins/saver的性能完全符合我的要求。 It pops up. 它弹出。 It lets the user authenticate in the popup. 它使用户可以在弹出窗口中进行身份验证。 It lets the user choose where they want to put my file. 它使用户可以选择他们要放置我的文件的位置。 But I can't send it a data uri, or base64-encoded data, or a bytearray, or whatever. 但是我无法向其发送数据uri,base64编码的数据,字节数组或任何其他内容。 It only works with files previously saved somewhere accessible on the net. 它仅适用于以前保存在网络上某个位置的文件。 So it does not work for me. 因此它对我不起作用。

https://www.newfangled.com/direct-javascript-dropbox-api-usage/ shows how I could embed the oauth data, which I don't have. https://www.newfangled.com/direct-javascript-dropbox-api-usage/展示了如何嵌入oauth数据,而我却没有。

https://blogs.dropbox.com/developers/2013/12/writing-a-file-with-the-dropbox-javascript-sdk/ seems like it should work, except that it's trying to perform an oauth session and it uses the same window as my app (which is undesired). https://blogs.dropbox.com/developers/2013/12/writing-a-file-with-the-dropbox-javascript-sdk/似乎应该可以使用,只是它尝试执行oauth会话并且使用与我的应用相同的窗口(不需要)。

My current tabs I'm looking at (includes entries from a few years ago, so things might have since changed). 我正在查看的当前标签页(包括几年前的条目,因此事情可能会有所改变)。 Some articles indicate that it isn't possible. 一些文章指出这是不可能的。 Other articles incidate that it IS possible - i mean this particular comment https://github.com/dropbox/dropbox-js/issues/144# doesn't help me much. 其他文章暗示这是可能的-我的意思是这个特殊评论https://github.com/dropbox/dropbox-js/issues/144#对我没有太大帮助。 Neither does "I'll be sure to pass this along as feedback" - was it passed along? “我一定会将此作为反馈传递”也没有传递-它传递了吗? To whom? 给谁?

It sounds like the code from https://blogs.dropbox.com/developers/2013/12/writing-a-file-with-the-dropbox-javascript-sdk/ works fine for you, but you want to do the auth in a separate browser window/tab. 听起来像来自https://blogs.dropbox.com/developers/2013/12/writing-a-file-with-the-dropbox-javascript-sdk/的代码对您来说很好用,但您想进行身份验证在单独的浏览器窗口/标签中。

If so, I'd suggest just changing that code to use the Popup auth driver instead. 如果是这样,我建议您仅更改该代码以使用Popup auth驱动程序即可

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM