Drive
Drive Class
The Drive
class provides methods to interact with a Deta Drive.
If you have not yet instantiated the Deta
Object, you must do so before you can use the Drive
Class.
No async implementation yet.
The Drive
class provides methods to interact with a Deta Drive.
Parameter | Type | Description |
---|---|---|
driveName | string | The name of the Drive. |
host? | string | The host of the Drive. |
The Drive
class provides methods to interact with a Deta Drive.
Parameter | Type | Description |
---|---|---|
d | *Deta | A pointer to a Deta instance. |
driveName | string | The name of the Drive. |
Returns a pointer to a Drive
instance.
The Drive
class provides methods to interact with a Deta Drive.
Parameter | Type | Description |
---|---|---|
name | str | The name of the Drive. |
host | str | None | The host of the Drive. |
Put
Uploads and stores a file with a given name. It will overwrite the file if the name already exists.
No async implementation yet.
Parameter | Type | Description |
---|---|---|
i | *PutInput | A pointer to a PutInput . |
Returns the name of the file on a successful put (otherwise empty name), and an error
.
Example:
Parameter | Type | Description |
---|---|---|
name | string | The name of the file. |
options | PutOptions | An object with three optional parameters. |
options
must have exactly one of two properties data
or path
defined.
data
is a Blob
or ArrayBuffer
of the file data.
path
is a string
of the path to the file on the local filesystem.
Returns a promise which resolves to a PutResponse
containing the name of the item.
If the operation did not complete successfully, throws an Error
.
Example:
Parameter | Type | Description |
---|---|---|
name | str | The name of the file. |
data | str | bytes | io.TextIOBase | io.BufferedIOBase | io.RawIOBase | The data content of the file. |
path | str | The local path of the file to be uploaded to drive. |
content_type | str | None | Content type of the file. If not provided, Drive tries to figure out the content type from the name . Defaults to application/octet-stream if it can not be determined. |
You must pass either data
or path
, but not both.
If name
is not a non-empty string, raises a ValueError
.
If neither or both data
and path
are passed, raises a ValueError
.
Returns an str
containing the name of the file.
If the operation did not complete successfully, raises an Exception
.
Example:
Get
Retrieves a file by its name.
No async implementation yet.
Parameter | Type | Description |
---|---|---|
name | string | The name of the file to get. |
Returns an io.ReadCloser
for the file, and an error
.
Example:
Parameter | Type | Description |
---|---|---|
name | string | The name of the file to get. |
Returns a promise that resolves to a GetResponse
containing a Blob
of the data if found, otherwise null
.
If the operation did not complete successfully, throws an Error
.
Example:
Parameter | Type | Description |
---|---|---|
name | str | The name of the file to get. |
Returns an instance of DriveStreamingBody
.
If name
is not a non-empty string, raises a ValueError
.
Example:
Delete
Deletes a file by its name.
No async implementation yet.
Parameter | Type | Description |
---|---|---|
name | string | The name of the file to delete. |
Returns the name of the deleted file on successful deletions, and an error
.
ℹ️ If the file did not exist, the name is still returned as if it were deleted.
Example:
Parameter | Type | Description |
---|---|---|
name | string | The name of the file to delete. |
Returns a promise that resolves to a DeleteResponse
containing the name
of the deleted file.
If the operation did not complete successfully, throws an Error
.
ℹ️ If the file did not exist, the name is still returned as if it were deleted.
Example:
Parameter | Type | Description |
---|---|---|
name | str | The name of the file to delete. |
Returns an str
containing the name of the deleted file.
If name
is not a non-empty string, raises a ValueError
.
If the operation did not complete successfully, raises an Exception
.
ℹ️ If the file did not exist, the name is still returned as if it were deleted.
Example:
Delete Many
Deletes multiple files, up to a limit of 1000.
No async implementation yet.
Parameter | Type | Description |
---|---|---|
names | string[] | The names of the files to delete. |
Returns a promise which resolves to a DeleteManyResponse
.
ℹ️ If the file did not exist, the name is still returned as if it were deleted.
Example:
Parameter | Type | Description |
---|---|---|
names | Sequence[str] | The names of the files to delete. |
Returns a dict
with "deleted"
and "failed"
keys indicating deleted and failed file names.
ℹ️ If the file did not exist, the name is still returned as if it were deleted.
Example:
Parameter | Type | Description |
---|---|---|
names | []string | The names of the files to delete. |
Returns a pointer to a DeleteManyOutput
, and an error
.
ℹ️ If the file did not exist, the name is still returned as if it were deleted.
Example:
List
Lists file names.
No async implementation yet.
Parameter | Type | Description |
---|---|---|
limit | int | The maximum number of file names to be returned. |
prefix | string | A prefix that file names must start with to be returned. |
last | string | The last name seen in a previous paginated result. |
Returns a pointer to a ListOutput
, and an error
.
Example:
Parameter | Type | Description |
---|---|---|
options | ListOptions | An object with three optional parameters. |
Returns a promise which resolves to a ListRepsonse
.
Example:
Parameter | Type | Description |
---|---|---|
limit | int | The maximum number of file names to be returned, defaults to 1000 . |
prefix | str | None | A prefix that file names must start with to be returned. |
last | str | None | The last name seen in a previous paginated result. |
Returns a dict
with "paging"
and "names"
keys.
"names"
: The names of the files."paging"
: Contains paging information."size"
: The number of files returned."last"
: The last name seen in the paginated response. Provide this value in subsequent api calls to fetch further pages. For the last page,last
is not present in the response.
Example:
DriveStreamingBody
The DriveStreamingBody
class provides methods to read the content of a file from a Drive (Python only).
Read
Reads all or up to the next size
bytes. Calling read
after all the content has been read will return empty bytes.
Iterate Chunks
Returns an iterator that yields chunks of bytes of chunk_size
at a time.
Iterate Lines
Returns an iterator that yields lines from the stream. Bytes of chunk_size
at a time is read from the raw stream and lines are yielded from there. The line delimiter is always b'\n'
.
Close
Closes the stream.
Closed
Returns True
if the stream has been closed.