From 31399fe47546eda0859288c206c4d01c756ee4e2 Mon Sep 17 00:00:00 2001 From: boojack Date: Sat, 4 Mar 2023 20:06:32 +0800 Subject: [PATCH] fix: s3 custom path (#1249) --- plugin/storage/s3/s3.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/plugin/storage/s3/s3.go b/plugin/storage/s3/s3.go index e00e9605..58fed5cd 100644 --- a/plugin/storage/s3/s3.go +++ b/plugin/storage/s3/s3.go @@ -67,11 +67,12 @@ func (client *Client) UploadFile(ctx context.Context, filename string, fileType } link := uploadOutput.Location - if link == "" { - if client.Config.URLPrefix == "" { - return "", fmt.Errorf("url prefix is empty") - } + // If url prefix is set, use it as the file link. + if client.Config.URLPrefix != "" { link = fmt.Sprintf("%s/%s", client.Config.URLPrefix, filename) } + if link == "" { + return "", fmt.Errorf("failed to get file link") + } return link, nil }