获取Dropbox文件上传后的永久链接

huangapple go评论74阅读模式
英文:

get Dropbox file PERMANENT URL when upload

问题

var updated = await dbx.Files.UploadAsync(
folder + "/" + file,
Dropbox.Api.Files.WriteMode.Overwrite.Instance,
body: mem);

var urlHelper = await dbx.Files.GetTemporaryLinkAsync(updated.PathDisplay);
house.MainImage = urlHelper.Link;

This code is working. urlHelper.Link give me ImageUrl but This url is temporary. After one day This url is not working.

For example: i set database this url yesterday: [Temporary URL]

This was working yesterday. But not now.

How can i get permanent URL ?

英文:
var updated = await dbx.Files.UploadAsync(
                                            folder + "/" + file,
                                             Dropbox.Api.Files.WriteMode.Overwrite.Instance,
                                            body: mem);

                                        var urlHelper = await dbx.Files.GetTemporaryLinkAsync(updated.PathDisplay);
                                        house.MainImage = urlHelper.Link;

This code is working. urlHelper.Link give me ImageUrl but This url is temporary. After one day This url is not working.

For example: i set database this url yesterday: https://uc278f948a5c22f08d40d0a49484.dl.dropboxusercontent.com/cd/0/get/B8u3K6GDYJZ_aliHLEpCzC8PvGZ9ERM8i9oHUAjFcbWFNK5Jjo50dg127AxfgWVozaphH6JQOvdsutWXpd0VZlCEXXWEttLjezEHQ6c87smtZxxfj8jLw1rZaqlK8P7kJnQSs1EMQ4n3YWWuYXTrN-xerpCvPiUWOZh-K_NbO0FDzlfKHsjcd9rgasGJelzIjnw/file

This was working yesterday. But not now.

How can i get permanent URL ?

答案1

得分: 1

如您所发现,GetTemporaryLinkAsync 返回的链接并不是永久的,只在几小时内有效。

如果您需要一个永不过期的链接,可以使用 CreateSharedLinkWithSettingsAsync。请注意,该方法返回的共享链接默认指向 HTML 预览页面,而不是文件内容。但您可以根据此处的文档修改这些链接以直接访问文件内容。

英文:

As you found, the links returned by GetTemporaryLinkAsync are not permanent and are only valid for a few hours.

If you need a non-expiring link, you can use CreateSharedLinkWithSettingsAsync instead. Note that the shared links returned by that method point to an HTML preview page by default and not the file content. You can modify those links for direct file content access as documented here though.

huangapple
  • 本文由 发表于 2023年5月26日 15:18:30
  • 转载请务必保留本文链接:https://go.coder-hub.com/76338485.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定