@@ -14,6 +14,7 @@ package obs
1414
1515import (
1616 "errors"
17+ "fmt"
1718 "io"
1819 "os"
1920 "strings"
@@ -200,6 +201,20 @@ func (obsClient ObsClient) GetObjectMetadata(input *GetObjectMetadataInput, exte
200201 return
201202}
202203
204+ func (obsClient ObsClient ) GetAttribute (input * GetAttributeInput , extensions ... extensionOptions ) (output * GetAttributeOutput , err error ) {
205+ if input == nil {
206+ return nil , errors .New ("GetAttributeInput is nil" )
207+ }
208+ output = & GetAttributeOutput {}
209+ err = obsClient .doActionWithBucketAndKey ("GetAttribute" , HTTP_HEAD , input .Bucket , input .Key , input , output , extensions )
210+ if err != nil {
211+ output = nil
212+ } else {
213+ ParseGetAttributeOutput (output )
214+ }
215+ return
216+ }
217+
203218// GetObject downloads object.
204219//
205220// You can use this API to download an object in a specified bucket.
@@ -231,7 +246,9 @@ func (obsClient ObsClient) PutObject(input *PutObjectInput, extensions ...extens
231246 output = & PutObjectOutput {}
232247 var repeatable bool
233248 if input .Body != nil {
234- _ , repeatable = input .Body .(* strings.Reader )
249+ if _ , ok := input .Body .(* strings.Reader ); ! ok {
250+ repeatable = false
251+ }
235252 if input .ContentLength > 0 {
236253 input .Body = & readerWrapper {reader : input .Body , totalCount : input .ContentLength }
237254 }
@@ -266,6 +283,26 @@ func (obsClient ObsClient) isGetContentType(input *PutObjectInput) bool {
266283 return false
267284}
268285
286+ func (obsClient ObsClient ) NewFolder (input * NewFolderInput , extensions ... extensionOptions ) (output * NewFolderOutput , err error ) {
287+ if input == nil {
288+ return nil , errors .New ("NewFolderInput is nil" )
289+ }
290+
291+ if ! strings .HasSuffix (input .Key , "/" ) {
292+ input .Key += "/"
293+ }
294+
295+ output = & NewFolderOutput {}
296+ err = obsClient .doActionWithBucketAndKey ("NewFolder" , HTTP_PUT , input .Bucket , input .Key , input , output , extensions )
297+ if err != nil {
298+ output = nil
299+ } else {
300+ ParseNewFolderOutput (output )
301+ output .ObjectUrl = fmt .Sprintf ("%s/%s/%s" , obsClient .conf .endpoint , input .Bucket , input .Key )
302+ }
303+ return
304+ }
305+
269306// PutFile uploads a file to the specified bucket.
270307func (obsClient ObsClient ) PutFile (input * PutFileInput , extensions ... extensionOptions ) (output * PutObjectOutput , err error ) {
271308 if input == nil {
@@ -361,7 +398,9 @@ func (obsClient ObsClient) AppendObject(input *AppendObjectInput, extensions ...
361398 output = & AppendObjectOutput {}
362399 var repeatable bool
363400 if input .Body != nil {
364- _ , repeatable = input .Body .(* strings.Reader )
401+ if _ , ok := input .Body .(* strings.Reader ); ! ok {
402+ repeatable = false
403+ }
365404 if input .ContentLength > 0 {
366405 input .Body = & readerWrapper {reader : input .Body , totalCount : input .ContentLength }
367406 }
@@ -389,7 +428,9 @@ func (obsClient ObsClient) ModifyObject(input *ModifyObjectInput, extensions ...
389428 output = & ModifyObjectOutput {}
390429 var repeatable bool
391430 if input .Body != nil {
392- _ , repeatable = input .Body .(* strings.Reader )
431+ if _ , ok := input .Body .(* strings.Reader ); ! ok {
432+ repeatable = false
433+ }
393434 if input .ContentLength > 0 {
394435 input .Body = & readerWrapper {reader : input .Body , totalCount : input .ContentLength }
395436 }
@@ -406,3 +447,35 @@ func (obsClient ObsClient) ModifyObject(input *ModifyObjectInput, extensions ...
406447 }
407448 return
408449}
450+
451+ func (obsClient ObsClient ) RenameFile (input * RenameFileInput , extensions ... extensionOptions ) (output * RenameFileOutput , err error ) {
452+ if input == nil {
453+ return nil , errors .New ("RenameFileInput is nil" )
454+ }
455+
456+ output = & RenameFileOutput {}
457+ err = obsClient .doActionWithBucketAndKey ("RenameFile" , HTTP_POST , input .Bucket , input .Key , input , output , extensions )
458+ if err != nil {
459+ output = nil
460+ }
461+ return
462+ }
463+
464+ func (obsClient ObsClient ) RenameFolder (input * RenameFolderInput , extensions ... extensionOptions ) (output * RenameFolderOutput , err error ) {
465+ if input == nil {
466+ return nil , errors .New ("RenameFolderInput is nil" )
467+ }
468+
469+ if ! strings .HasSuffix (input .Key , "/" ) {
470+ input .Key += "/"
471+ }
472+ if ! strings .HasSuffix (input .NewObjectKey , "/" ) {
473+ input .NewObjectKey += "/"
474+ }
475+ output = & RenameFolderOutput {}
476+ err = obsClient .doActionWithBucketAndKey ("RenameFolder" , HTTP_POST , input .Bucket , input .Key , input , output , extensions )
477+ if err != nil {
478+ output = nil
479+ }
480+ return
481+ }
0 commit comments