Data Platform Buckets connector
In the current Data Platform SDK, the Datastore connector is used to interact with the Data Platform Buckets
Objective
In the current Data Platform SDK, the Datastore connector is used to interact with the Data Platform Buckets. You may think of the Datastore simply as a bucket container.
Connect to the Datastore
In order to interact with the Datastore you have to connect to it first, as shown in the code below:
After that you can use the cn_datastore.list() method to see the buckets available in your Datastore and then connect to the bucket of your choice to interact with it.
You can connect directly to a specific bucket in the Datastore as shown in the code below:
The datastore connector will return a Data Store Connector object and connecting directly to a bucket will return a Bucket Connector object.
See the next section of this article for additional details on the methods of each connector.
Datastore Connector methods
datastore.list(return_type = 'array')
Lists all buckets in the Datastore.
Input Parameters
Output
datastore.get_buckets()
Gets all buckets from the Datastore
Output
datastore.get_bucket(name)
Gets a bucket instance from its name.
Input Parameters
Output
datastore.create_bucket(name)
Adds a bucket in the Data Store.
Input Parameters
Output
datastore.remove_bucket(name)
Removes a bucket from the Data Store.
Input Parameters
Output
datastore.bucket_exists(name)
Finds out if a bucket exists or not.
Input Parameters
Output
Bucket Connector methods
bucket.list(bool metadata=True, bool recursive=True, **kwargs)
Lists files from Data Store's bucket.
Input Parameters
Output
Short Example
bucket.list_filename(return_type='array', contains='', recursive=True, **kwargs)
Lists filenames from Data Store's bucket.
Input Parameters
Output
Short Example
bucket.get(file_name, **kwargs)
Gets raw file content from a Data Store bucket.
Input Parameters
Output
Short Example
bucket.fget(object_name, file_path, **kwargs)
Gets an object from Datastore's bucket to local path.
Input Parameters
Output
Short Example
bucket.put(object_name, data, int length, **kwargs)
Puts an object to Data Store's bucket.
Input Parameters
Output
Short Example
bucket.fput(object_name, file_path, **kwargs)
Puts a file to Data Store's bucket.
Input Parameters
Output
Short Example
bucket.put_request(url, path, data={}, method='GET', headers={}, **kwargs)
Gets an object from an HTTP request and upload it to Datastore's bucket.
Input Parameters
Short Example
bucket.delete(path, **kwargs)
Deletes multiple/single file in Data Store's bucket.
Input Parameters
Short Example
bucket.fcopy_to(new_bucket, object_name, object_source, **kwargs)
Copies file from bucket to a new bucket in Data Store.
Input Parameters
Short Example
bucket.exists(filename, **kwargs)
Checks whether a file exists in the bucket.
Input Parameters
Output
Short Example
bucket.get_content(file_name, **kwargs)
Retrieves the full content of a file from the bucket.
Input Parameters
Output
Short Example
bucket.get_path(path)
Returns the full qualified path (URL or reference) of an object in the bucket.
Input Parameters
Output
Short Example
bucket.remove_path(path)
Removes a specific path from the bucket.
Input Parameters
Output
Short Example
Deprecated Methods
The bucket.stat() method is no longer supported and has been deprecated. Use exists() or get_content() as alternatives depending on your use case.
Additional methods
The Data Platform Datastore is built on Minio technology. Please refer to the Minio Technical Documentation for more information on the advanced settings of the SDK functions.
Go further
If you need training or technical assistance to implement our solutions, contact your sales representative or click on this link to get a quote and ask our Professional Services experts for a custom analysis of your project.
Ask questions, give your feedback and interact directly with the team building the Data Platform on the dedicated Discord channel.
If you need support with your OVHcloud services, create a request in our Help Centre.
Join our community of users.

