support for "rm" of objects and buckets

This commit is contained in:
Krishna Srinivas
2015-10-19 15:11:59 -07:00
parent 2a3b201457
commit b4c78a33ff
7 changed files with 242 additions and 0 deletions
+1
View File
@@ -40,6 +40,7 @@ type Client interface {
ShareUpload(bool, time.Duration, string) (map[string]string, *probe.Error)
GetObject(offset, length int64) (body io.ReadCloser, size int64, err *probe.Error)
PutObject(size int64, data io.Reader) *probe.Error
Remove() *probe.Error
// URL returns back internal url
URL() *URL
+5
View File
@@ -191,6 +191,11 @@ func (f *fsClient) GetObject(offset, length int64) (io.ReadCloser, int64, *probe
return body, length, nil
}
func (f *fsClient) Remove() *probe.Error {
err := os.Remove(f.Path)
return probe.NewError(err)
}
// List - list files and folders
func (f *fsClient) List(recursive bool) <-chan client.ContentOnChannel {
contentCh := make(chan client.ContentOnChannel)
+12
View File
@@ -76,6 +76,18 @@ func (c *s3Client) GetObject(offset, length int64) (io.ReadCloser, int64, *probe
return reader, metadata.Size, nil
}
// Remove - remove object or bucket
func (c *s3Client) Remove() *probe.Error {
bucket, object := c.url2BucketAndObject()
var err error
if object == "" {
err = c.api.RemoveBucket(bucket)
} else {
err = c.api.RemoveObject(bucket, object)
}
return probe.NewError(err)
}
// Share - get a usable get object url to share
func (c *s3Client) ShareDownload(expires time.Duration) (string, *probe.Error) {
bucket, object := c.url2BucketAndObject()
+12
View File
@@ -76,6 +76,18 @@ func (c *s3Client) GetObject(offset, length int64) (io.ReadCloser, int64, *probe
return reader, metadata.Size, nil
}
// Remove - remove object or bucket
func (c *s3Client) Remove() *probe.Error {
bucket, object := c.url2BucketAndObject()
var err error
if object == "" {
err = c.api.RemoveBucket(bucket)
} else {
err = c.api.RemoveObject(bucket, object)
}
return probe.NewError(err)
}
// Share - get a usable get object url to share
func (c *s3Client) ShareDownload(expires time.Duration) (string, *probe.Error) {
bucket, object := c.url2BucketAndObject()