Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

Create direct share link for "koofr" backend

Dmitry Bogatovbb11803f1f54
diff --git a/backend/koofr/koofr.go b/backend/koofr/koofr.go
index 26dbcc9e7..d9addd369 100644
--- a/backend/koofr/koofr.go
+++ b/backend/koofr/koofr.go
@@ -608,5 +608,25 @@ func (f *Fs) PublicLink(ctx context.Context, remote string, expire fs.Duration,
if err != nil {
return "", translateErrorsDir(err)
}
- return linkData.ShortURL, nil
+
+ // URL returned by API looks like following:
+ //
+ // https://app.koofr.net/links/35d9fb92-74a3-4930-b4ed-57f123bfb1a6
+ //
+ // Direct url looks like following:
+ //
+ // https://app.koofr.net/content/links/39a6cc01-3b23-477a-8059-c0fb3b0f15de/files/get?path=%2F
+ //
+ // I am not sure about meaning of "path" parameter; in my expriments
+ // it is always "%2F", and omitting it or putting any other value
+ // results in 404.
+ //
+ // There is one more quirk: direct link to file in / returns that file,
+ // direct link to file somewhere else in hierarchy returns zip archive
+ // with one member.
+ link := linkData.URL
+ link = strings.ReplaceAll(link, "/links", "/content/links")
+ link += "/files/get?path=%2F"
+
+ return link, nil
}