Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UploadRequest creates ObjectStorageClient when uploading request is processing. #441

Open
urunimi opened this issue Jul 9, 2023 · 1 comment
Labels
Object Storage Issue pertains to the Object Storage service

Comments

@urunimi
Copy link

urunimi commented Jul 9, 2023

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.

if request.ObjectStorageClient == nil {
client, err := objectstorage.NewObjectStorageClientWithConfigurationProvider(common.DefaultConfigProvider())
// default timeout is 60s which includes the time for reading the body
// default timeout doesn't work for big file, here will use the default
// 0s which means no timeout
client.HTTPClient = &http.Client{}
if err != nil {
return err
}
request.ObjectStorageClient = &client
}

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)
	// ...
}
@KartikShrikantHegde
Copy link

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

@KartikShrikantHegde KartikShrikantHegde added the Object Storage Issue pertains to the Object Storage service label Jul 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Object Storage Issue pertains to the Object Storage service
Projects
None yet
Development

No branches or pull requests

2 participants