Always make sure to verify argument validation in checkSyntax**.
Cleanup share-upload.go to be aware of different argument validation.
This commit is contained in:
+4
-4
@@ -62,7 +62,7 @@ func (f *fsClient) fsStat() (os.FileInfo, *probe.Error) {
|
||||
// Resolve symlinks
|
||||
fpath, err := filepath.EvalSymlinks(fpath)
|
||||
if runtime.GOOS == "windows" {
|
||||
// On windows there are directory symlinks
|
||||
// On windows there are folder symlinks
|
||||
// which are called junction files which
|
||||
// carry special meaning on windows
|
||||
// - which cannot be accessed with regular operations
|
||||
@@ -252,7 +252,7 @@ func (f *fsClient) listInRoutine(contentCh chan client.ContentOnChannel) {
|
||||
if fi.Mode()&os.ModeSymlink == os.ModeSymlink {
|
||||
fi, err = os.Stat(filepath.Join(dir.Name(), fi.Name()))
|
||||
if os.IsPermission(err) {
|
||||
// On windows there are directory symlinks
|
||||
// On windows there are folder symlinks
|
||||
// which are called junction files which
|
||||
// carry special meaning on windows
|
||||
// - which cannot be accessed with regular operations
|
||||
@@ -348,7 +348,7 @@ func (f *fsClient) listRecursiveInRoutine(contentCh chan client.ContentOnChannel
|
||||
}
|
||||
if os.IsPermission(err) {
|
||||
if runtime.GOOS == "windows" {
|
||||
// On windows there are directory symlinks
|
||||
// On windows there are folder symlinks
|
||||
// which are called junction files which
|
||||
// carry special meaning on windows
|
||||
// - which cannot be accessed with regular operations
|
||||
@@ -384,7 +384,7 @@ func (f *fsClient) listRecursiveInRoutine(contentCh chan client.ContentOnChannel
|
||||
if err != nil {
|
||||
if os.IsPermission(err) {
|
||||
if runtime.GOOS == "windows" {
|
||||
// On windows there are directory symlinks
|
||||
// On windows there are folder symlinks
|
||||
// which are called junction files which
|
||||
// carry special meaning on windows
|
||||
// - which cannot be accessed with regular operations
|
||||
|
||||
+14
-5
@@ -89,15 +89,24 @@ func (c *s3Client) ShareDownload(expires time.Duration) (string, *probe.Error) {
|
||||
func (c *s3Client) ShareUpload(recursive bool, expires time.Duration, contentType string) (map[string]string, *probe.Error) {
|
||||
bucket, object := c.url2BucketAndObject()
|
||||
p := minio.NewPostPolicy()
|
||||
p.SetExpires(time.Now().UTC().Add(expires))
|
||||
if len(contentType) > 0 {
|
||||
if err := p.SetExpires(time.Now().UTC().Add(expires)); err != nil {
|
||||
return nil, probe.NewError(err)
|
||||
}
|
||||
if strings.TrimSpace(contentType) != "" || contentType != "" {
|
||||
// No need to check for errors here, we have trimmed off the spaces
|
||||
p.SetContentType(contentType)
|
||||
}
|
||||
p.SetBucket(bucket)
|
||||
if err := p.SetBucket(bucket); err != nil {
|
||||
return nil, probe.NewError(err)
|
||||
}
|
||||
if recursive {
|
||||
p.SetKeyStartsWith(object)
|
||||
if err := p.SetKeyStartsWith(object); err != nil {
|
||||
return nil, probe.NewError(err)
|
||||
}
|
||||
} else {
|
||||
p.SetKey(object)
|
||||
if err := p.SetKey(object); err != nil {
|
||||
return nil, probe.NewError(err)
|
||||
}
|
||||
}
|
||||
m, err := c.api.PresignedPostPolicy(p)
|
||||
return m, probe.NewError(err)
|
||||
|
||||
+14
-5
@@ -89,15 +89,24 @@ func (c *s3Client) ShareDownload(expires time.Duration) (string, *probe.Error) {
|
||||
func (c *s3Client) ShareUpload(recursive bool, expires time.Duration, contentType string) (map[string]string, *probe.Error) {
|
||||
bucket, object := c.url2BucketAndObject()
|
||||
p := minio.NewPostPolicy()
|
||||
p.SetExpires(time.Now().UTC().Add(expires))
|
||||
if len(contentType) > 0 {
|
||||
if err := p.SetExpires(time.Now().UTC().Add(expires)); err != nil {
|
||||
return nil, probe.NewError(err)
|
||||
}
|
||||
if strings.TrimSpace(contentType) != "" || contentType != "" {
|
||||
// No need to verify for error here, since we have stripped out spaces
|
||||
p.SetContentType(contentType)
|
||||
}
|
||||
p.SetBucket(bucket)
|
||||
if err := p.SetBucket(bucket); err != nil {
|
||||
return nil, probe.NewError(err)
|
||||
}
|
||||
if recursive {
|
||||
p.SetKeyStartsWith(object)
|
||||
if err := p.SetKeyStartsWith(object); err != nil {
|
||||
return nil, probe.NewError(err)
|
||||
}
|
||||
} else {
|
||||
p.SetKey(object)
|
||||
if err := p.SetKey(object); err != nil {
|
||||
return nil, probe.NewError(err)
|
||||
}
|
||||
}
|
||||
m, err := c.api.PresignedPostPolicy(p)
|
||||
return m, probe.NewError(err)
|
||||
|
||||
Reference in New Issue
Block a user