@Generated public class FilesAPI extends Object
The API supports [Unity Catalog volumes], where files and directories to operate on are specified using their volume URI path, which follows the format /Volumes/<catalog_name>/<schema_name>/<volume_name>/<path_to_file>.
The Files API has two distinct endpoints, one for working with files (`/fs/files`) and another one for working with directories (`/fs/directories`). Both endpoints, use the standard HTTP methods GET, HEAD, PUT, and DELETE to manage files and directories specified using their URI path. The path is always absolute.
[Unity Catalog volumes]: https://docs.databricks.com/en/connect/unity-catalog/volumes.html
Constructor and Description |
---|
FilesAPI(ApiClient apiClient)
Regular-use constructor
|
FilesAPI(FilesService mock)
Constructor for mocks
|
public FilesAPI(ApiClient apiClient)
public FilesAPI(FilesService mock)
public void createDirectory(String directoryPath)
public void createDirectory(CreateDirectoryRequest request)
Creates an empty directory. If necessary, also creates any parent directories of the new, empty directory (like the shell command `mkdir -p`). If called on an existing directory, returns a success response; this method is idempotent (it will succeed if the directory already exists).
public void delete(String filePath)
public void delete(DeleteFileRequest request)
Deletes a file. If the request is successful, there is no response body.
public void deleteDirectory(String directoryPath)
public void deleteDirectory(DeleteDirectoryRequest request)
Deletes an empty directory.
To delete a non-empty directory, first delete all of its contents. This can be done by listing the directory contents and deleting each file and subdirectory recursively.
public DownloadResponse download(String filePath)
public DownloadResponse download(DownloadRequest request)
Downloads a file of up to 5 GiB. The file contents are the response body. This is a standard HTTP file download, not a JSON RPC.
public void getDirectoryMetadata(String directoryPath)
public void getDirectoryMetadata(GetDirectoryMetadataRequest request)
Get the metadata of a directory. The response HTTP headers contain the metadata. There is no response body.
This method is useful to check if a directory exists and the caller has access to it.
If you wish to ensure the directory exists, you can instead use `PUT`, which will create the directory if it does not exist, and is idempotent (it will succeed if the directory already exists).
public GetMetadataResponse getMetadata(String filePath)
public GetMetadataResponse getMetadata(GetMetadataRequest request)
Get the metadata of a file. The response HTTP headers contain the metadata. There is no response body.
public Iterable<DirectoryEntry> listDirectoryContents(String directoryPath)
public Iterable<DirectoryEntry> listDirectoryContents(ListDirectoryContentsRequest request)
Returns the contents of a directory. If there is no directory at the specified path, the API returns a HTTP 404 error.
public void upload(String filePath, InputStream contents)
public void upload(UploadRequest request)
Uploads a file of up to 5 GiB. The file contents should be sent as the request body as raw bytes (an octet stream); do not encode or otherwise modify the bytes before sending. The contents of the resulting file will be exactly the bytes sent in the request body. If the request is successful, there is no response body.
public FilesService impl()
Copyright © 2024. All rights reserved.