我收到了来自电子商务公司的共享文件夹链接。该链接是公开的,不直接与我的 Dropbox 帐户共享。
如何获取可以传递给同一个 sdk 的 DownloadAsync 方法或只是 HttpClient 的图像的 url,然后......下载它?
理想情况下,它与我在浏览器中查看该共享文件夹时单击图像时获得的链接相同。
https://www.dropbox.com/sh/{folder_hash}/{file_hash_maybe}/{filename}?dl=0
这是我尝试过的:
using Dropbox.Api;
using Dropbox.Api.Files;
...
var accessToken = "abracadabra";
var sharedFolderUrl = "https://www.dropbox.com/sh/{folder_hash}?dl=0";
using (var dbx = new DropboxClient(accessToken))
{
var sharedLink = new SharedLink(sharedFolderUrl);
var sharedFiles = await dbx.Files.ListFolderAsync(path: "", sharedLink: sharedLink);
// sharedFiles - has over 13,000 entries, I use cursor to get them all.
foreach (var file in sharedFiles.Entries)
{
if (file.IsFile)
{
// tried this, but:
// 1. it's crazy to loop through all
// 2. link.Response.Url gives me the same url to a shared folder for all items
var link = await dbx.Sharing.GetSharedLinkFileAsync(url: sharedFolderUrl, path: "/" + file.Name);
}
}
}