fix: remove leading / from s3 paths
This commit is contained in:
parent
295b76aad2
commit
bf34c77269
|
@ -111,7 +111,7 @@ func (db *DB) WriteMemberAvatar(ctx context.Context,
|
|||
}
|
||||
hash = hex.EncodeToString(hasher.Sum(nil))
|
||||
|
||||
_, err = db.minio.PutObject(ctx, db.minioBucket, "/members/"+memberID.String()+"/"+hash+".webp", webp, -1, minio.PutObjectOptions{
|
||||
_, err = db.minio.PutObject(ctx, db.minioBucket, "members/"+memberID.String()+"/"+hash+".webp", webp, -1, minio.PutObjectOptions{
|
||||
ContentType: "image/webp",
|
||||
SendContentMd5: true,
|
||||
})
|
||||
|
@ -119,7 +119,7 @@ func (db *DB) WriteMemberAvatar(ctx context.Context,
|
|||
return "", errors.Wrap(err, "uploading webp avatar")
|
||||
}
|
||||
|
||||
_, err = db.minio.PutObject(ctx, db.minioBucket, "/members/"+memberID.String()+"/"+hash+".jpg", jpeg, -1, minio.PutObjectOptions{
|
||||
_, err = db.minio.PutObject(ctx, db.minioBucket, "members/"+memberID.String()+"/"+hash+".jpg", jpeg, -1, minio.PutObjectOptions{
|
||||
ContentType: "image/jpeg",
|
||||
SendContentMd5: true,
|
||||
})
|
||||
|
@ -131,12 +131,12 @@ func (db *DB) WriteMemberAvatar(ctx context.Context,
|
|||
}
|
||||
|
||||
func (db *DB) DeleteUserAvatar(ctx context.Context, userID xid.ID, hash string) error {
|
||||
err := db.minio.RemoveObject(ctx, db.minioBucket, "/users/"+userID.String()+"/"+hash+".webp", minio.RemoveObjectOptions{})
|
||||
err := db.minio.RemoveObject(ctx, db.minioBucket, "users/"+userID.String()+"/"+hash+".webp", minio.RemoveObjectOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "deleting webp avatar")
|
||||
}
|
||||
|
||||
err = db.minio.RemoveObject(ctx, db.minioBucket, "/users/"+userID.String()+"/"+hash+".jpg", minio.RemoveObjectOptions{})
|
||||
err = db.minio.RemoveObject(ctx, db.minioBucket, "users/"+userID.String()+"/"+hash+".jpg", minio.RemoveObjectOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "deleting jpeg avatar")
|
||||
}
|
||||
|
@ -145,12 +145,12 @@ func (db *DB) DeleteUserAvatar(ctx context.Context, userID xid.ID, hash string)
|
|||
}
|
||||
|
||||
func (db *DB) DeleteMemberAvatar(ctx context.Context, memberID xid.ID, hash string) error {
|
||||
err := db.minio.RemoveObject(ctx, db.minioBucket, "/members/"+memberID.String()+"/"+hash+".webp", minio.RemoveObjectOptions{})
|
||||
err := db.minio.RemoveObject(ctx, db.minioBucket, "members/"+memberID.String()+"/"+hash+".webp", minio.RemoveObjectOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "deleting webp avatar")
|
||||
}
|
||||
|
||||
err = db.minio.RemoveObject(ctx, db.minioBucket, "/members/"+memberID.String()+"/"+hash+".jpg", minio.RemoveObjectOptions{})
|
||||
err = db.minio.RemoveObject(ctx, db.minioBucket, "members/"+memberID.String()+"/"+hash+".jpg", minio.RemoveObjectOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "deleting jpeg avatar")
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ func (db *DB) DeleteMemberAvatar(ctx context.Context, memberID xid.ID, hash stri
|
|||
}
|
||||
|
||||
func (db *DB) UserAvatar(ctx context.Context, userID xid.ID, hash string) (io.ReadCloser, error) {
|
||||
obj, err := db.minio.GetObject(ctx, db.minioBucket, "/users/"+userID.String()+"/"+hash+".webp", minio.GetObjectOptions{})
|
||||
obj, err := db.minio.GetObject(ctx, db.minioBucket, "users/"+userID.String()+"/"+hash+".webp", minio.GetObjectOptions{})
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "getting object")
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ func (db *DB) UserAvatar(ctx context.Context, userID xid.ID, hash string) (io.Re
|
|||
}
|
||||
|
||||
func (db *DB) MemberAvatar(ctx context.Context, memberID xid.ID, hash string) (io.ReadCloser, error) {
|
||||
obj, err := db.minio.GetObject(ctx, db.minioBucket, "/members/"+memberID.String()+"/"+hash+".webp", minio.GetObjectOptions{})
|
||||
obj, err := db.minio.GetObject(ctx, db.minioBucket, "members/"+memberID.String()+"/"+hash+".webp", minio.GetObjectOptions{})
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "getting object")
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ type DataExport struct {
|
|||
}
|
||||
|
||||
func (de DataExport) Path() string {
|
||||
return "/exports/" + de.UserID.String() + "/" + de.Filename + ".zip"
|
||||
return "exports/" + de.UserID.String() + "/" + de.Filename + ".zip"
|
||||
}
|
||||
|
||||
const ErrNoExport = errors.Sentinel("no data export exists")
|
||||
|
|
|
@ -69,7 +69,7 @@
|
|||
Download your export file below:
|
||||
</p>
|
||||
<p>
|
||||
<Button color="primary" href="{PUBLIC_MEDIA_URL}{data.exportData.path}" target="_blank"
|
||||
<Button color="primary" href="{PUBLIC_MEDIA_URL}/{data.exportData.path}" target="_blank"
|
||||
>Download data export</Button
|
||||
>
|
||||
</p>
|
||||
|
|
Loading…
Reference in New Issue