mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-12-04 02:39:01 +08:00
cloud drive: gcs simplify a little bit
This commit is contained in:
parent
95a6e0226d
commit
12631a3f5b
@ -110,24 +110,16 @@ func (gcs *gcsRemoteStorageClient) WriteFile(loc *filer_pb.RemoteStorageLocation
|
||||
|
||||
key := loc.Path[1:]
|
||||
|
||||
metadata := toMetadata(entry.Extended)
|
||||
wc := gcs.client.Bucket(loc.Bucket).Object(key).NewWriter(context.Background())
|
||||
wc.Metadata = metadata
|
||||
if _, err = io.Copy(wc, reader); err != nil {
|
||||
wc.Close()
|
||||
return nil, fmt.Errorf("upload to gcs %s/%s%s: %v", loc.Name, loc.Bucket, loc.Path, err)
|
||||
}
|
||||
if err = wc.Close(); err != nil {
|
||||
return nil, fmt.Errorf("close gcs %s/%s%s: %v", loc.Name, loc.Bucket, loc.Path, err)
|
||||
}
|
||||
|
||||
metadata := toMetadata(entry.Extended)
|
||||
if len(metadata) > 0 {
|
||||
if _, err = gcs.client.Bucket(loc.Bucket).Object(key).Update(context.Background(), storage.ObjectAttrsToUpdate{
|
||||
Metadata: metadata,
|
||||
}); err != nil {
|
||||
return nil, fmt.Errorf("update metadata gcs %s/%s%s: %v", loc.Name, loc.Bucket, loc.Path, err)
|
||||
}
|
||||
}
|
||||
|
||||
// read back the remote entry
|
||||
return gcs.readFileRemoteEntry(loc)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user