oracle / oci-go-sdk

Go SDK for Oracle Cloud Infrastructure
https://cloud.oracle.com/cloud-infrastructure
Other
178 stars 82 forks source link

Cannot add custom meta data to object to be uploaded on object storage #186

Open satyavvd opened 5 years ago

satyavvd commented 5 years ago

with below piece of code I see this error: "panic: runtime error: invalid memory address or nil pointer dereference"

goroutine 1 [running]: github.com/oracle/oci-go-sdk/objectstorage/transfer.(multipartUpload).createMultipartUpload(0x9f23c0, 0x7c95c0, 0xc0000580c0, 0xc0001d00f0, 0xc0001d0100, 0xc0001d0110, 0xc0001bc0a8, 0xc0001bc568, 0xc0001bc569, 0xc0001bc560, ...) go/src/github.com/oracle/oci-go-sdk/objectstorage/transfer/mutipart_uploader.go:42 +0x1ff github.com/oracle/oci-go-sdk/objectstorage/transfer.(fileUpload).UploadFileMultiparts(0xc0001c21b0, 0x7c95c0, 0xc0000580c0, 0xc0001d00f0, 0xc0001d0100, 0xc0001d0110, 0xc0001bc0a8, 0xc0001bc568, 0xc0001bc569, 0xc0001bc560, ...) go/src/github.com/oracle/oci-go-sdk/objectstorage/transfer/file_uploader.go:48 +0x1a0 github.com/oracle/oci-go-sdk/objectstorage/transfer.(*UploadManager).UploadFile(0xc000081b38, 0x7c95c0, 0xc0000580c0, 0xc0001d00f0, 0xc0001d0100, 0xc0001d0110, 0xc0001bc0a8, 0xc0001bc568, 0xc0001bc569, 0xc0001bc560, ...) go/src/github.com/oracle/oci-go-sdk/objectstorage/transfer/upload_manager.go:81 +0x391 main.uploadFile(0xc0001bc0a0, 0x8, 0x759759, 0xd, 0xc0001d60c0, 0x24, 0xc000081cf0, 0x7c95c0, 0xc0000580c0, 0x0, ...) go/go_obj_upload.go:145 +0x40b main.main() go/go_obj_upload.go:111 +0x873

   var metadata = map[string]string{
    "test": "test meta data",
}

uploadManager := transfer.NewUploadManager()

req := transfer.UploadFileRequest{
    UploadRequest: transfer.UploadRequest{
        NamespaceName: common.String(namespace),
        BucketName:    common.String(bucket),
        ObjectName:    common.String(fileInfo.Name()),
                    Metadata :  metadata,
    },
    FilePath: file,
}

resp, err := uploadManager.UploadFile(ctx, req

===================================================

srinivasthanneeru commented 5 years ago

quick workaround, prefix metdata key with opc-meta, eg.as below metadata["opc-meta-test"] = "srinit..."

srinivasthanneeru commented 5 years ago

BTW. It works without above work around for single file upload

jasonyin commented 5 years ago

@srinivasthanneeru in the upload manager request there's an optional metadata parameter https://github.com/oracle/oci-go-sdk/blob/master/objectstorage/transfer/upload_manager_req_resp.go#L75

are you saying without it the bulk upload will throw exception?

srinivasthanneeru commented 5 years ago

Hi Jason,

It expects keys to be prefixed with opc-meta. If we supply metadata without the prefix, the multi part upload fails. However for single file upload it works fine without prefixing opc-meta. I believe it should be transparent to end consumer of SDK, SDK should prepend if the key doesn't have opc-meta* prefix.

Hope that clarifies Thanks Srini

On Fri, Oct 4, 2019 at 10:24 AM Jason Yin notifications@github.com wrote:

@srinivasthanneeru https://github.com/srinivasthanneeru in the upload manager request there's an optional metadata parameter https://github.com/oracle/oci-go-sdk/blob/master/objectstorage/transfer/upload_manager_req_resp.go#L75

are you saying without it the bulk upload will throw exception?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/oracle/oci-go-sdk/issues/186?email_source=notifications&email_token=AFBPSK2P2WMP57G6E47C6HDQM536HA5CNFSM4ITHYNQKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEAMKZ5A#issuecomment-538488052, or mute the thread https://github.com/notifications/unsubscribe-auth/AFBPSKYGMXHP2KRLWK6YQS3QM536HANCNFSM4ITHYNQA .

jasonyin commented 5 years ago

Got it, we will be working on a fix for auto adding opc-meta prefix on client side.

BTW, for multi-part md5 verification change, it will be release out today.