Get Files
The ExaDrive SDK provides powerful methods to retrieve information about files stored in your ExaDrive. These functionalities allow you to efficiently manage and access your stored files.
Retrieving All Files
The getAllFiles()
method allows you to fetch a list of all files stored in your ExaDrive.
Syntax
Example
Response Structure
The method returns a promise that resolves with an array of file objects. Each object contains detailed information about a file.
Response Fields
fileName: The name of the file.
fileDetails: An object containing:
encoding: The file's encoding (e.g., "7bit").
mimetype: The MIME type of the file.
size: The file size in bytes.
url: The URL where the file can be accessed.
Retrieving a Specific File
To get information about a specific file, use the getFile()
method.
Syntax
fileName
: A string representing the name of the file you want to retrieve.
Example
Response Structure
The method returns a promise that resolves with an object containing detailed information about the specified file.
Advanced Usage
Pagination for Large File Lists
If you have a large number of files, implement pagination:
Filtering Files
Implement a function to filter files based on certain criteria:
Best Practices
Error Handling: Always include error handling to manage potential failures gracefully.
Caching: Consider implementing a caching mechanism for frequently accessed file information to reduce API calls.
Rate Limiting: Be aware of any rate limits on API calls and implement appropriate throttling if necessary.
Large Data Sets: For applications dealing with a large number of files, implement pagination or batching to manage memory usage and improve performance.
Regular Syncing: If your application requires up-to-date file information, consider implementing a regular syncing mechanism:
By utilizing these file management capabilities and following best practices, you can effectively organize and access your files stored in ExaDrive using the SDK.
Last updated