oci-go-sdk icon indicating copy to clipboard operation
oci-go-sdk copied to clipboard

`UploadRequest` creates `ObjectStorageClient` when uploading request is processing.

Open urunimi opened this issue 2 years ago • 1 comments

I don't think it is good idea to create ObjectStorageClient instance while uploading.

How about return error instantly if the client is not set?

I used long time to debug this issue and I can create a pull request.

https://github.com/oracle/oci-go-sdk/blob/a172b320b82f9d45afe9a044511d4eba550d06d1/objectstorage/transfer/upload_manager_req_resp.go#L144-L157

func New() (CloudStorage, error) {
	// I used `ConfigurationProviderEnvironmentVariables` to create the configuration.
	conf := common.ConfigurationProviderEnvironmentVariables("oci", "")
	// It passes `IsConfigurationProviderValid`. 
	c, err := objectstorage.NewObjectStorageClientWithConfigurationProvider(conf)
	// ...
}

func (s *ociObjectStorage) Upload(objectName string, data []byte) error {
	// ...
	uploadManager := transfer.NewUploadManager()

	req := transfer.UploadStreamRequest{
		UploadRequest: transfer.UploadRequest{
			NamespaceName:                       &namespace,
			BucketName:                          &bname,
			ObjectName:                          &objectName,
			EnableMultipartChecksumVerification: common.Bool(true),
		},
		// ...
	}

	// I got a client error if `ObjectStorageClient` is set manually.
	_, err := uploadManager.UploadStream(ctx, req)
	// ...
}

urunimi avatar Jul 09 '23 14:07 urunimi

@urunimi assigning this issue to the Object Storage team to take a look and suggest.

KartikShrikantHegde avatar Jul 11 '23 23:07 KartikShrikantHegde