Fallback to default S3 URL on empty media upload URL in settings.

This commit is contained in:
Kailash Nadh 2021-10-04 22:20:24 +05:30
parent d91d6e5ce3
commit b46ab6d3a9
2 changed files with 3 additions and 4 deletions

View file

@ -95,8 +95,7 @@
label-position="on-border"
:message="$t('settings.media.s3.urlHelp')" expanded>
<b-input v-model="data['upload.s3.url']"
name="upload.s3.url"
:disabled="!data['upload.s3.bucket']"
name="upload.s3.url" :disabled="!data['upload.s3.bucket']" required
placeholder="https://s3.region.amazonaws.com" :maxlength="200" />
</b-field>
</div>

View file

@ -1,7 +1,7 @@
package s3
import (
"errors"
"fmt"
"io"
"strings"
"time"
@ -36,7 +36,7 @@ func NewS3Store(opt Opt) (media.Store, error) {
err error
)
if opt.URL == "" {
return nil, errors.New("Invalid AWS URL in settings.")
opt.URL = fmt.Sprintf("https://s3.%s.amazonaws.com", opt.Region)
}
opt.URL = strings.TrimRight(opt.URL, "/")