Merge pull request #386 from harshavardhana/pr_out_implement_getpartial_for_fsclient_and_renamed_files_unix_go_as_we_bring_in_windows_specific_support

This commit is contained in:
Harshavardhana
2015-04-16 17:38:28 -07:00
4 changed files with 19 additions and 4 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
#
# Minio Commander, (C) 2015 Minio, Inc.
# Modern Copy, (C) 2015 Minio, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -79,11 +79,26 @@ func (f *fsClient) Get(bucket, object string) (body io.ReadCloser, size int64, m
}
// GetPartial - download a partial object from bucket
func (f *fsClient) GetPartial(bucket, key string, offset, length int64) (body io.ReadCloser, size int64, md5 string, err error) {
func (f *fsClient) GetPartial(bucket, object string, offset, length int64) (body io.ReadCloser, size int64, md5 string, err error) {
if offset < 0 {
return nil, 0, "", iodine.New(client.InvalidRange{Offset: offset}, nil)
}
return nil, 0, "", iodine.New(client.APINotImplemented{API: "GetPartial"}, nil)
objectPath, st, err := isValidObject(bucket, object)
if err != nil {
return nil, 0, "", iodine.New(err, nil)
}
body, err = os.Open(objectPath)
if err != nil {
return nil, 0, "", iodine.New(err, nil)
}
if offset > st.Size() || (offset+length-1) > st.Size() {
return nil, 0, "", iodine.New(client.InvalidRange{Offset: offset}, nil)
}
_, err = io.CopyN(ioutil.Discard, body, offset)
if err != nil {
return nil, 0, "", iodine.New(err, nil)
}
return body, length, "", nil
}
// StatObject -
@@ -99,7 +114,7 @@ func (f *fsClient) GetObjectMetadata(bucket, object string) (item *client.Item,
item.Key = object
item.Size = st.Size()
item.LastModified = st.ModTime()
item.ETag = "" // TODO
item.ETag = "" // TODO, doesn't exist yet
return item, nil
}