Nest Storage is a module for Nest.js that simplifies interaction with various storage providers. It offers a flexible and extensible approach to handle storage operations in your Nest.js applications.
To use Nest Storage in your Nest.js application, install the package via npm:
npm install @eleven-am/nestjs-storage
import { StorageModule } from '@eleven-am/nestjs-storage';
@Module({
imports: [
StorageModule.forRoot({
provider: Provider.LOCAL, // Choose your storage provider
// Add provider-specific options as needed
}),
],
})
export class YourModule {}
import { Injectable } from '@nestjs/common';
import { StorageService } from 'nest-storage';
@Injectable()
export class YourService {
constructor(private readonly storageService: StorageService) {}
// Use storageService methods for file and folder operations
// Example: this.storageService.putFile('path/to/file.txt', bufferData);
}
-
Local Storage:
Provider.LOCAL
-
Google Drive Storage:
Provider.GDRIVE
-
Dropbox Storage:
Provider.DROPBOX
-
Amazon S3 Storage:
Provider.S3
andProvider.R2
Certainly! Here's the same API section with reduced font size for the function names:
Uploads a file to the storage provider at the specified path.
-
Parameters:
-
path
(string): The destination path for the file. -
data
(Buffer): The data to be stored.
-
Retrieves information about a file or folder from the storage provider.
-
Parameters:
-
fileId
(string): The identifier of the file or folder.
-
Reads the content of a file from the storage provider.
-
Parameters:
-
fileId
(string): The identifier of the file.
-
Deletes a file or folder from the storage provider.
-
Parameters:
-
fileId
(string): The identifier of the file or folder.
-
Moves a file or folder to a new location within the storage provider.
-
Parameters:
-
fileId
(string): The identifier of the file or folder. -
newPath
(string): The new path for the file or folder.
-
Renames a file or folder in the storage provider.
-
Parameters:
-
fileId
(string): The identifier of the file or folder. -
newName
(string): The new name for the file or folder.
-
Creates a new folder in the storage provider.
-
Parameters:
-
path
(string): The path for the new folder.
-
Reads the contents of a folder from the storage provider.
-
Parameters:
-
folderId
(string): The identifier of the folder.
-
Returns the current storage provider name.
-
Returns:
- (string): The name of the storage provider (
LOCAL
,GDRIVE
,DROPBOX
,S3
, orR2
).
- (string): The name of the storage provider (
Contributions are welcome! If you find any issues or have suggestions, feel free to open an issue or create a pull request.
This project is licensed under the GPL 3.0 License.