Package dev.dosya.sdk.resource
Class FilesResource
java.lang.Object
dev.dosya.sdk.resource.FilesResource
Provides operations for managing files in Dosya workspaces.
This resource handles listing, retrieving, deleting, restoring, renaming, moving, copying, locking, hiding, versioning, and sharing files.
- Since:
- 0.1.0
-
Constructor Summary
ConstructorsConstructorDescriptionFilesResource(@NotNull DosyaHttpClient http) Creates a newFilesResourcebacked by the given HTTP client. -
Method Summary
Modifier and TypeMethodDescription@NotNull FileDetailCopies a file using the original name and folder.@NotNull FileDetailCopies a file, optionally with a new name and/or into a different folder.@NotNull ShareBundleLinkcreateShareBundle(@NotNull CreateShareBundleParams params) Creates a share bundle containing multiple files as a single shareable link.@NotNull ShareLinkDetailcreateShareLink(@NotNull String fileId) Creates a new share link for a file with default settings.@NotNull ShareLinkDetailcreateShareLink(@NotNull String fileId, @Nullable CreateShareLinkParams params) Creates a new share link for a file with optional configuration.booleanDeletes a file.@NotNull FileDetailRetrieves detailed information about a single file.@NotNull List<ShareLinkDetail>getShareLinks(@NotNull String fileId) Retrieves all share links associated with a file.voidHides a file using the default hidden mode.voidHides a file, optionally specifying a hidden mode and target user/group IDs.@NotNull ListFilesResponselist(@NotNull ListFilesParams params) Lists files and folders in a workspace, optionally filtered by folder, query, or status.@NotNull FileVersionsResponselistVersions(@NotNull String fileId) Lists all versions of a file.voidLocks a file with the specified lock mode without a password.voidLocks a file with the specified lock mode and optional password.voidMoves a file into a different folder.@NotNull StringRenames a file and returns the new name.voidRestores a previously soft-deleted file.@NotNull VersionRestoreResponserestoreVersion(@NotNull String fileId, int versionNumber) Restores a file to a previous version.voidshareByEmail(@NotNull String fileId, @NotNull List<String> emails, @Nullable String message) Shares a file by sending email invitations to the specified recipients.voidRemoves the lock from a file.
-
Constructor Details
-
FilesResource
Creates a newFilesResourcebacked by the given HTTP client.- Parameters:
http- the HTTP client used to make API requests
-
-
Method Details
-
list
Lists files and folders in a workspace, optionally filtered by folder, query, or status.- Parameters:
params- the listing parameters including workspace ID, pagination, and filters- Returns:
- the response containing files, folders, breadcrumbs, and pagination info
- Throws:
DosyaApiException- if the API returns an error
-
get
Retrieves detailed information about a single file.- Parameters:
fileId- the unique identifier of the file- Returns:
- the file detail
- Throws:
DosyaApiException- if the API returns an error
-
delete
Deletes a file. Returns whether the deletion was permanent.- Parameters:
fileId- the unique identifier of the file to delete- Returns:
trueif the file was permanently deleted,falseif soft-deleted- Throws:
DosyaApiException- if the API returns an error
-
restore
Restores a previously soft-deleted file.- Parameters:
fileId- the unique identifier of the file to restore- Throws:
DosyaApiException- if the API returns an error
-
rename
@NotNull public @NotNull String rename(@NotNull @NotNull String fileId, @NotNull @NotNull String name) Renames a file and returns the new name.- Parameters:
fileId- the unique identifier of the filename- the new name for the file- Returns:
- the updated file name as confirmed by the server
- Throws:
DosyaApiException- if the API returns an error
-
move
Moves a file into a different folder.- Parameters:
fileId- the unique identifier of the file to movefolderId- the target folder ID- Throws:
DosyaApiException- if the API returns an error
-
copy
@NotNull public @NotNull FileDetail copy(@NotNull @NotNull String fileId, @Nullable @Nullable String newName, @Nullable @Nullable String folderId) Copies a file, optionally with a new name and/or into a different folder.- Parameters:
fileId- the unique identifier of the file to copynewName- the name for the copy, ornullto keep the original namefolderId- the target folder ID for the copy, ornullto keep the same folder- Returns:
- the detail of the newly created copy
- Throws:
DosyaApiException- if the API returns an error
-
copy
Copies a file using the original name and folder.- Parameters:
fileId- the unique identifier of the file to copy- Returns:
- the detail of the newly created copy
- Throws:
DosyaApiException- if the API returns an error
-
lock
public void lock(@NotNull @NotNull String fileId, @NotNull @NotNull String lockMode, @Nullable @Nullable String password) Locks a file with the specified lock mode and optional password.- Parameters:
fileId- the unique identifier of the file to locklockMode- the lock mode (e.g. "password", "readonly")password- the password for the lock, ornullif not required- Throws:
DosyaApiException- if the API returns an error
-
lock
Locks a file with the specified lock mode without a password.- Parameters:
fileId- the unique identifier of the file to locklockMode- the lock mode (e.g. "password", "readonly")- Throws:
DosyaApiException- if the API returns an error
-
unlock
Removes the lock from a file.- Parameters:
fileId- the unique identifier of the file to unlock- Throws:
DosyaApiException- if the API returns an error
-
hide
public void hide(@NotNull @NotNull String fileId, @Nullable @Nullable String hiddenMode, @Nullable @Nullable List<String> targetIds) Hides a file, optionally specifying a hidden mode and target user/group IDs.- Parameters:
fileId- the unique identifier of the file to hidehiddenMode- the hidden mode, ornullfor the defaulttargetIds- the list of user or group IDs to hide the file from, ornull- Throws:
DosyaApiException- if the API returns an error
-
hide
Hides a file using the default hidden mode.- Parameters:
fileId- the unique identifier of the file to hide- Throws:
DosyaApiException- if the API returns an error
-
listVersions
Lists all versions of a file.- Parameters:
fileId- the unique identifier of the file- Returns:
- the response containing the file name, current version, and version history
- Throws:
DosyaApiException- if the API returns an error
-
restoreVersion
@NotNull public @NotNull VersionRestoreResponse restoreVersion(@NotNull @NotNull String fileId, int versionNumber) Restores a file to a previous version.- Parameters:
fileId- the unique identifier of the fileversionNumber- the version number to restore- Returns:
- the response containing the new version number and the version it was restored from
- Throws:
DosyaApiException- if the API returns an error
-