Dropboxを使用すると、DropboxフォルダにURLをドラッグ&ドロップすることでショートカットを作成できます。 ダウンロードしたBLOBをHTTPを使用してdropbox APIから読み取る
のDropboxから/2/files/download HTTP APIを使用すると、次のようになりますXHRレスポンスを返します:
あなただけつかむことができるようにどのようにこの応答を解析しますこれは、このように保存されます。 URLをクリックしてクリック可能なリンクにしますか?
Dropboxを使用すると、DropboxフォルダにURLをドラッグ&ドロップすることでショートカットを作成できます。 ダウンロードしたBLOBをHTTPを使用してdropbox APIから読み取る
のDropboxから/2/files/download HTTP APIを使用すると、次のようになりますXHRレスポンスを返します:
あなただけつかむことができるようにどのようにこの応答を解析しますこれは、このように保存されます。 URLをクリックしてクリック可能なリンクにしますか?
ここでは、Angular 1工場に入る必要があります。これを使用するには、コントローラからdownloadFile関数を呼び出し、Dropboxアカウントのファイルへのパスを渡すだけです。
function downloadFile(filePath) {
if (!filePath) {
console.error('Cannot download file because no file was specified.');
return;
}
return $q(function(fulfill, reject) {
$http({
url: 'https://content.dropboxapi.com/2/files/download',
method: 'POST',
headers: {
'Authorization': 'Bearer {{access-token-goes-here}}',
'Dropbox-API-Arg': `{"path": "${filePath}"}`
},
responseType: 'blob'
}).then(
results => {
// data received from dropbox is binary data saved as a blob
// The FileReader object lets web applications asynchronously read the contents of files
// https://developer.mozilla.org/en-US/docs/Web/API/FileReader
var fileReader = new FileReader();
// function will run after successfully reading the file
fileReader.onload = function() {
var string = this.result; // store the file contents
string = encodeURI(string); // get rid of the paragraph return characters
var endPosition = string.indexOf('%0D%0A', 32); // find the end of the URL, startPosition is 32
var actualURL = string.substring(32, endPosition); // grab only the characters between start and end positions
fulfill(actualURL);
};
fileReader.readAsText(results.data);
},
error => reject(error));
});
}
ところで、潜在的に含まれる可能性のあるものがあるように見えるので、32桁目からの目的のURLデータに頼るのではなく、データを完全に解析することをお勧めします。たとえば、この非公式ガイドをご覧ください。http://www.lyberty.com/encyc/articles/tech/dot_url_format_-_an_unofficial_guide.html – Greg
[参照のための架橋:https://www.dropboxforum.com/t5/API-support/Get-the-URL-path-from-a-link-bookmark-url-file/mp/199000#M9218] – Greg