From bb11803f1f542a60aaf93c0894c1af8c285c300b Mon Sep 17 00:00:00 2001 From: Dmitry Bogatov Date: Thu, 10 Jun 2021 00:00:00 +0000 Subject: [PATCH] Create direct share link for "koofr" backend Instead of creating link to web interface, create direct link usable by curl(1) or wget(1). --- backend/koofr/koofr.go | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) 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 }