@@ -382,6 +382,26 @@ func (metadata *ObjectMetadata) serialize() ([]byte, error) {
382382 return result , nil
383383}
384384
385+ func (metadata * ObjectMetadata ) UnmarshalJSON (data []byte ) error {
386+ var aux struct {
387+ RawMeta struct {
388+ Entry []struct {
389+ Key string `json:"key"`
390+ Value string `json:"value"`
391+ } `json:"entry"`
392+ } `json:"rawMeta"`
393+ }
394+ if err := json .Unmarshal (data , & aux ); err != nil {
395+ return err
396+ }
397+
398+ metadata .metadata = make (map [string ]string , len (aux .RawMeta .Entry ))
399+ for _ , kv := range aux .RawMeta .Entry {
400+ metadata .metadata [kv .Key ] = kv .Value
401+ }
402+ return nil
403+ }
404+
385405func parseObjectMetadataFromHeader (header http.Header ) * ObjectMetadata {
386406 objectMetadata := NewObjectMetadata ()
387407 for k := range header {
@@ -875,3 +895,39 @@ func (client *Client) SetObjectPublicWithContext(ctx context.Context, bucketName
875895
876896 return client .SetObjectACLWithContext (ctx , aclRequest )
877897}
898+
899+ type ObjectBasicInfo struct {
900+ AllowOutsideAccess * bool `json:"allowOutsideAccess,omitempty"`
901+ Size int64 `json:"size"`
902+ UploadTime int64 `json:"uploadTime"`
903+ StorageClassType StorageClass `json:"storageClass"`
904+ Metadata ObjectMetadata `json:"metadataBean"`
905+ }
906+
907+ type getObjectBasicInfoOption struct {
908+ BasicInfo string `param:"basicInfo" header:"-"`
909+ }
910+
911+ // GetObjectBasicInfo
912+ func (client * Client ) GetObjectBasicInfo (bucketName , objectName string ) (* ObjectBasicInfo , error ) {
913+ return client .GetObjectBasicInfoWithContext (context .Background (), bucketName , objectName )
914+ }
915+
916+ func (client * Client ) GetObjectBasicInfoWithContext (ctx context.Context , bucketName , objectName string ) (* ObjectBasicInfo , error ) {
917+ result := & ObjectBasicInfo {}
918+ req := & clientRequest {
919+ BucketName : bucketName ,
920+ ObjectName : objectName ,
921+ Method : HTTPGet ,
922+ QueryHeaderOptions : getObjectBasicInfoOption {},
923+ Result : result ,
924+ }
925+
926+ resp , err := client .do (ctx , req )
927+ if err != nil {
928+ return nil , err
929+ }
930+ defer resp .Body .Close ()
931+
932+ return result , nil
933+ }
0 commit comments