Skip to main content

UploadService

Trait UploadService 

Source
pub trait UploadService<O, I: Iterator<Item = Result<Bytes, Error>>> {
    // Required methods
    fn initiate_multipart_upload(
        &self,
        auth_: &BearerToken,
        upload_request: &InitiateMultipartUploadRequest,
    ) -> Result<InitiateMultipartUploadResponse, Error>;
    fn list_parts(
        &self,
        auth_: &BearerToken,
        upload_id: &str,
        key: &str,
    ) -> Result<Vec<PartWithSize>, Error>;
    fn sign_part(
        &self,
        auth_: &BearerToken,
        upload_id: &str,
        key: &str,
        part_number: i32,
    ) -> Result<SignPartResponse, Error>;
    fn complete_multipart_upload(
        &self,
        auth_: &BearerToken,
        upload_id: &str,
        key: &str,
        parts: &[Part],
    ) -> Result<CompleteMultipartUploadResponse, Error>;
    fn abort_multipart_upload(
        &self,
        auth_: &BearerToken,
        upload_id: &str,
        key: &str,
    ) -> Result<(), Error>;
    fn sign_download(
        &self,
        auth_: &BearerToken,
        request: &SignDownloadRequest,
    ) -> Result<SignDownloadResponse, Error>;
    fn upload_file(
        &self,
        auth_: &BearerToken,
        file_name: &str,
        size_bytes: Option<SafeLong>,
        workspace: Option<&WorkspaceRid>,
        body: impl WriteBody<O>,
    ) -> Result<S3Path, Error>;
}
Expand description

The Upload Service manages file uploads to object storage.

Required Methods§

Source

fn initiate_multipart_upload( &self, auth_: &BearerToken, upload_request: &InitiateMultipartUploadRequest, ) -> Result<InitiateMultipartUploadResponse, Error>

Initiates a multipart upload to object storage. Returns an uploadId that should be used with listParts, signPart, and completeMultipartUpload.

Source

fn list_parts( &self, auth_: &BearerToken, upload_id: &str, key: &str, ) -> Result<Vec<PartWithSize>, Error>

Lists the parts that have been uploaded for a given uploadId.

Source

fn sign_part( &self, auth_: &BearerToken, upload_id: &str, key: &str, part_number: i32, ) -> Result<SignPartResponse, Error>

Signs an upload request for a single part. Returns a URL that will execute the upload without further authentication.

Source

fn complete_multipart_upload( &self, auth_: &BearerToken, upload_id: &str, key: &str, parts: &[Part], ) -> Result<CompleteMultipartUploadResponse, Error>

Completes a multipart upload to object storage. This should be called after all parts have been uploaded. Will throw EmptyMultipartUpload if there are 0 parts.

Source

fn abort_multipart_upload( &self, auth_: &BearerToken, upload_id: &str, key: &str, ) -> Result<(), Error>

Aborts a multipart upload to S3. Frees storage used by previously uploaded parts and prevents further uploads to the same uploadId.

Source

fn sign_download( &self, auth_: &BearerToken, request: &SignDownloadRequest, ) -> Result<SignDownloadResponse, Error>

Returns a short-lived signed GET URL for an object already in the uploads bucket. Use this to hand a freshly-uploaded object’s path to an external service (e.g. Dagger) without giving that service any Scout credentials. The caller must be authorized to read the workspace that owns the path (encoded as the first segment of the object key).

Source

fn upload_file( &self, auth_: &BearerToken, file_name: &str, size_bytes: Option<SafeLong>, workspace: Option<&WorkspaceRid>, body: impl WriteBody<O>, ) -> Result<S3Path, Error>

Uploads a file to S3. Intended for smaller files.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<O, I: Iterator<Item = Result<Bytes, Error>>, __C> UploadService<O, I> for UploadServiceClient<__C>
where __C: Client<BodyWriter = O, ResponseBody = I>,