add helper function for handling existing file in s3
This commit is contained in:
@@ -35,7 +35,7 @@ func extensionFromContentType(ct string) string {
|
||||
return exts[0]
|
||||
}
|
||||
|
||||
func getKey(hash string, contentType string) string {
|
||||
func GetKey(hash string, contentType string) string {
|
||||
return hash + extensionFromContentType(contentType)
|
||||
}
|
||||
|
||||
@@ -78,15 +78,12 @@ func Upload(ctx context.Context, key string, body io.Reader, size int64, content
|
||||
return err
|
||||
}
|
||||
|
||||
func getDownloadUrl(ctx context.Context, key string) (*url.URL, error) {
|
||||
func GetDownloadUrl(ctx context.Context, key string) (*url.URL, error) {
|
||||
u, err := minClient.PresignedGetObject(ctx, globals.FileStorageBucketName, key, globals.FileDownloadLinkTtl, nil)
|
||||
return u, err
|
||||
}
|
||||
|
||||
func DoesExist(ctx context.Context, key string) bool {
|
||||
_, err := minClient.GetObject(ctx, globals.FileStorageBucketName, key, minio.GetObjectOptions{})
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
_, err := minClient.StatObject(ctx, globals.FileStorageBucketName, key, minio.StatObjectOptions{})
|
||||
return err == nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user