Acquire.Client._drive module¶
-
class
Drive(user=None, name=None, storage_service=None, storage_url=None, autocreate=True)[source]¶ Bases:
objectThis class provides a handle to a user’s drive (space to hold files and folders). A drive is associated with a single storage service and can be shared amongst several users. Each drive has a unique UID, with users assiging their own shorthand names.
-
acl()[source]¶ Return the access control list for the user on this drive. If the ACL is not known, then None is returned
Returns: Access Control List for the user Return type: str
-
aclrules()[source]¶ Return the ACL rules used to grant access to this drive. This is only visible to owners of this drive. If it is not visible, then None is returned
Returns: ACL rules for the drive Return type: str
-
bulk_upload(max_size=None, aclrules=None)[source]¶ Start the bulk upload of a large number of files to this drive, assuming we have write access to this drive. This will return a bulk upload PAR that can be used to write to a bucket. All of the files written to this bucket will be copied into this drive using the (optionally) supplied aclrules to control access (or “inherit” if no rules are supplied).
Once you have finished uploading, you must call the “close” function on the BulkUploadPAR so that the files are correctly copied. The filenames as they are written to the PAR will be used, creating new files (and subdrives) as needed
- Args:
- max_size (int, default=None): Max size for upload aclrules (str, default=None): ACL rules for upload
- Returns:
- str: Name of drive
-
download(filename, downloaded_name=None, version=None, dir=None, force_par=False)[source]¶ Download the file called ‘filename’ from this drive into the local directory, or ‘dir’ if specified, ideally called ‘filename’ (or ‘downloaded_name’ if that is specified). If a local file exists with this name, then a new, unique filename will be used. This returns a dictionary mapping the downloaded filename to the FileMeta of the file
Note that this only downloads files for which you have read-access. If the file is not readable then an exception is raised and nothing is returned
If ‘version’ is specified then download a specific version of the file. Otherwise download the latest version
Parameters: - filename (str) – Name of file to download
- downloaded_name (str, default=None) – Name of file once downloaded
- version (datetime, default=None) – Datetime denoting version
- file to use (of) –
- dir (str, default=None) – Directory for file
- force_par (bool, default=False) – If True force a pre-authenticated
- be created for the download (request) –
Returns: Object containing metadata on the uploaded file
Return type:
-
guid()[source]¶ Return the global UID of this drive (combination of the UID of the storage service and UID of the drive)
Returns: Global UID for drive Return type: str
-
is_null()[source]¶ Return whether or not this drive is null
Returns: True if null, else False Return type: bool
-
list_drives()[source]¶ Return a list of the DriveMetas of all of the drives contained in this drive that are accessible to the user
Returns: List of DriveMetas for the drives Return type: list
-
list_files(include_metadata=False)[source]¶ Return a list of the FileMetas of all of the files contained in this drive
Parameters: - include_metadata (bool, default=False) – If True include
- for the returned files (metadata) –
Returns: List of FileMetas for files in drive
Return type: list
-
static
list_toplevel_drives(user, storage_service=None, storage_url=None)[source]¶ Return a list of all of the DriveMetas of the drives accessible at the top-level by the passed user on the passed storage service
Parameters: Returns: List of DriveMetas for the drives
Return type: list
-
list_versions(filename, include_metadata=False)[source]¶ Return a list of all of the versions of the specified file. This returns an empty list if there are no versions of this file
Parameters: - filename – Filename for listing of versions
- include_metadata (bool, default=False) – If True include
- for the returned files (metadata) –
Returns: List of FileMetas for versions of file
Return type: list
-
name()[source]¶ Return the name given to this drive by the user
Returns: Name of drive Return type: str
-
storage_service()[source]¶ Return the storage service for this drive
Returns: Storage service for drive Return type: Service
-
upload(filename, uploaded_name=None, aclrules=None, force_par=False)[source]¶ Upload the file at ‘filename’ to this drive, assuming we have write access to this drive. The local file ‘filename’ will be uploaded to the drive as the file called ‘filename’ (just the filename - not the full path). If you want to specify the uploaded name then set this as “uploaded_name” (which again will just be a filename - no paths). If a file with this name exists, then this will upload a new version (assuming you have permission). Otherwise this will create a new file. You can set the ACL rules used to grant access to this file via ‘aclrule’. If this is not set, then the rules will be derived from either the last version of the file, or inherited from the drive.
Parameters: - filename (str) – Name of file to upload
- uploaded_name (str, default=None) – Name of file once uploaded
- aclrules (str, default=None) – ACL rules for file
- force_par (bool, default=False) – If True force a pre-authenticated
- be created for the upload (request) –
- Returns:
- FileMeta: Object containing metadata on the uploaded file
-