簡體   English   中英

Dropbox選擇器:使用javascript獲取文件內容

[英]Dropbox chooser : get content of the file in javascript

我在HTML5應用程序中使用了保管箱選擇器,而API並沒有給您文件本身,而是提供了直接鏈接來下載文件。 類似於:“ https://dl.dropboxusercontent.com/1/view/ydld54fs5sford8/myFolder/myFile.csv ”。

我如何設法使用javascript下載此文件以獲得文件對象,然后讀取該文件的內容?

您可以只使用標准的AJAX調用。 例如,使用jQuery:

$.get('https://dl.dropboxusercontent.com/1/...', function (data) {
    console.log(data); // <-- this will log the contents of the file
});

編輯

確保您使用的是直接鏈接(看起來像https://dl.dropboxusercontent.com/1/... ),而不是預覽鏈接(指向www.dropbox.com上的HTML頁面)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM