security: Update go-uuid and mholt/archiver to recommended version (#2216)
* security: Update go-uuid to recommended version * security: Update mholt/archiver dep to recommended version Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>
This commit is contained in:
@@ -32,10 +32,14 @@ func (ls localStorage) getStorageType() StorageType {
|
||||
return ls.storageType
|
||||
}
|
||||
|
||||
func (ls localStorage) getUploadFileName() string {
|
||||
func (ls localStorage) getUploadFileName() (string, error) {
|
||||
// This is not the item ID (that's returned by Put)
|
||||
// should we just use handler.Filename? what are the constraints here?
|
||||
return uuid.NewV4().String()
|
||||
id, err := uuid.NewV4()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return id.String(), err
|
||||
}
|
||||
|
||||
func (ls localStorage) getContainerName() string {
|
||||
|
||||
@@ -49,9 +49,12 @@ func (ss s3Storage) getContainerName() string {
|
||||
return ss.bucketName
|
||||
}
|
||||
|
||||
func (ss s3Storage) getUploadFileName() string {
|
||||
uploadName := uuid.NewV4().String()
|
||||
return path.Join(ss.subDir, uploadName)
|
||||
func (ss s3Storage) getUploadFileName() (string, error) {
|
||||
id, err := uuid.NewV4()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return path.Join(ss.subDir, id.String()), nil
|
||||
}
|
||||
|
||||
func (ss s3Storage) dial() (stow.Location, error) {
|
||||
|
||||
@@ -40,7 +40,7 @@ type (
|
||||
dial() (stow.Location, error)
|
||||
// getSubDir() string
|
||||
getContainerName() string
|
||||
getUploadFileName() string
|
||||
getUploadFileName() (string, error)
|
||||
}
|
||||
|
||||
// StorageService is a struct to hold all things for storage service
|
||||
|
||||
@@ -111,7 +111,10 @@ func MakeStowClient(logger *zap.Logger, storage Storage) (*StowClient, error) {
|
||||
|
||||
// putFile writes the file on the storage
|
||||
func (client *StowClient) putFile(file multipart.File, fileSize int64) (string, error) {
|
||||
uploadName := client.config.storage.getUploadFileName()
|
||||
uploadName, err := client.config.storage.getUploadFileName()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
// save the file to the storage backend
|
||||
item, err := client.container.Put(uploadName, file, fileSize, nil)
|
||||
|
||||
Reference in New Issue
Block a user