Package dev.dosya.sdk.resource
Class UploadResource
java.lang.Object
dev.dosya.sdk.resource.UploadResource
Provides operations for uploading files to Dosya workspaces.
Supports single-part and multipart uploads with automatic concurrency, progress tracking, and resumable upload sessions.
- Since:
- 0.1.0
-
Constructor Summary
ConstructorsConstructorDescriptionUploadResource(@NotNull DosyaHttpClient http) Creates a newUploadResourcebacked by the given HTTP client. -
Method Summary
Modifier and TypeMethodDescription@NotNull UploadResultfile(@NotNull UploadParams params) Uploads a file using the provided parameters.@NotNull UploadInitResponseinit(@NotNull String workspaceId, @NotNull String fileName, long fileSize, @Nullable String mimeType, @Nullable String region, @Nullable String folderId, @Nullable String fileId) Initializes an upload session with the Dosya API.@NotNull UploadResultresume(@NotNull String sessionId, @org.jetbrains.annotations.NotNull byte[] body, @Nullable Consumer<UploadProgress> onProgress) Resumes a previously started multipart upload session.@NotNull UploadStatusResponseRetrieves the current status of an upload session.
-
Constructor Details
-
UploadResource
Creates a newUploadResourcebacked by the given HTTP client.- Parameters:
http- the HTTP client used to make API requests
-
-
Method Details
-
file
Uploads a file using the provided parameters. Automatically selects single-part or multipart upload based on the server response.- Parameters:
params- the upload parameters including workspace ID, file data, and optional settings- Returns:
- the upload result containing the uploaded file detail and session ID
- Throws:
DosyaUploadException- if the upload failsDosyaApiException- if the API returns an error
-
resume
@NotNull public @NotNull UploadResult resume(@NotNull @NotNull String sessionId, @NotNull @org.jetbrains.annotations.NotNull byte[] body, @Nullable @Nullable Consumer<UploadProgress> onProgress) Resumes a previously started multipart upload session.- Parameters:
sessionId- the upload session ID to resumebody- the full file bytes to uploadonProgress- an optional callback for progress updates, ornull- Returns:
- the upload result containing the uploaded file detail and session ID
- Throws:
DosyaUploadException- if the session is already complete, not multipart, or the upload failsDosyaApiException- if the API returns an error
-
init
@NotNull public @NotNull UploadInitResponse init(@NotNull @NotNull String workspaceId, @NotNull @NotNull String fileName, long fileSize, @Nullable @Nullable String mimeType, @Nullable @Nullable String region, @Nullable @Nullable String folderId, @Nullable @Nullable String fileId) Initializes an upload session with the Dosya API.- Parameters:
workspaceId- the workspace to upload intofileName- the name of the file being uploadedfileSize- the total file size in bytesmimeType- the MIME type of the file, ornullfor auto-detectionregion- the storage region, ornullfor the defaultfolderId- the target folder ID, ornullfor the workspace rootfileId- an existing file ID for versioned re-upload, ornull- Returns:
- the initialization response containing session ID and upload instructions
- Throws:
DosyaApiException- if the API returns an error
-
status
Retrieves the current status of an upload session.- Parameters:
sessionId- the upload session ID- Returns:
- the status response including uploaded parts and progress
- Throws:
DosyaApiException- if the API returns an error
-