benchling_sdk.services.v2.stable.blob_service module¶
- class BlobService¶
Bases:
benchling_sdk.services.v2.base_service.BaseService
Blobs.
Blobs are opaque files that can be linked to other items in Benchling, like assay runs or results. For example, you can upload a blob, then upload an assay result that links to that blob by ID. The blob will then appear as part of the assay result in the Benchling web UI.
See https://benchling.com/api/reference#/Blobs
- abort_multipart_upload(blob_id: str) None ¶
Abort multi-part blob upload.
See https://benchling.com/api/reference#/Blobs/abortMultipartBlob
- complete_multipart_upload(blob_id: str, blob_parts: Iterable[BlobPart]) Blob ¶
Combine Blob parts into a single Blob.
See https://benchling.com/api/reference#/Blobs/completeMultipartBlob
- create(blob: BlobCreate, timeout_seconds: float = DEFAULT_HTTP_TIMEOUT) Blob ¶
Upload a single-part blob.
Blobs larger than 10MB should be uploaded in multiple parts. The data64 parameter is the base64-encoded part contents, and the md5 parameter is the hex-encoded MD5 hash of the part contents. For example, given the string hello, data64 is aGVsbG8= and md5 is 5d41402abc4b2a76b9719d911017c592
- create_from_bytes(input_bytes: Union[_io.BytesIO, bytes], name: str, mime_type: Optional[str] = None, blob_type: BlobCreateType = BlobCreateType.RAW_FILE, timeout_seconds: float = DEFAULT_HTTP_TIMEOUT, chunk_size_bytes: int = DEFAULT_CHUNK_SIZE_BYTES) Blob ¶
Create a Benchling Blob from bytes or a BytesIO stream.
Will automatically attempt a multi-part upload if the stream appears larger than the APIâs maximum size for single Blobs.
- Parameters
input_bytes â The bytes or stream to upload
name â The name of the Blob in Benchling
mime_type â The representative MIME type for the Blob
blob_type â The type of Blob in Benchling (Visualization or Raw File)
timeout_seconds â Extends the normal HTTP timeout settings since Blob uploads can be large Use this to extend even further if streams are very large
chunk_size_bytes â The size in bytes for each chunk when using a multipart upload. If the bytes exceed chunk_size_bytes, multipart will automatically be attempted. Otherwise, single Blob upload will be used
- Returns
The created Blob
- Return type
- create_from_file(file_path: Path, name: Optional[str] = None, mime_type: Optional[str] = None, blob_type: BlobCreateType = BlobCreateType.RAW_FILE, auto_detect: bool = True, timeout_seconds: float = DEFAULT_HTTP_TIMEOUT, chunk_size_bytes: int = DEFAULT_CHUNK_SIZE_BYTES) Blob ¶
Create a Benchling Blob from a file.
Will automatically attempt a multi-part upload if the file appears larger than the APIâs maximum size for single Blobs.
- Parameters
file_path â The Path to the file to upload
name â The name of the Blob in Benchling
mime_type â The representative mime type for the Blob
blob_type â The type of Blob in Benchling (Visualization or Raw File)
auto_detect â Will attempt to guess the fileâs MIME type if mime_type was not specified and auto_detect is True
timeout_seconds â Extends the normal HTTP timeout settings since Blob uploads can be large Use this to extend even further if streams are very large
chunk_size_bytes â The size in bytes for each chunk when using a multipart upload. If the bytes exceed chunk_size_bytes, multipart will automatically be attempted. Otherwise, single Blob upload will be used
- Returns
The created Blob
- Return type
- create_multipart_upload(multipart_blob: BlobMultipartCreate) Blob ¶
Initiate multi-part Blob upload.
See https://benchling.com/api/reference#/Blobs/createMultipartBlob
- create_part(blob_id: str, blob_part: BlobPartCreate, timeout_seconds: float = DEFAULT_HTTP_TIMEOUT) BlobPart ¶
Upload a part of a multi-part Blob.
Larger files and slower connections will likely need to set a higher timeout_seconds value in order to complete successful part uploads.
See https://benchling.com/api/reference#/Blobs/createBlobPart
- download_bytes(blob_id: str) _io.BytesIO ¶
Download a Blob in its entirety from Benchling and write it to BytesIO.
- download_file(blob_id: str, destination_path: Optional[Path] = None) Path ¶
Download a Blob from Benchling and writes it to a file.
If specified, destination_path must be a reference to a file and not a directory. It must also not already exist on the file system. If destination_path is None, a temporary file will be created for writing.