Search code examples
c#.netfile-uploaddropbox

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: 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 ?


Solution

  • 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.