lingapp-file
Version:
Mongoose model for managing files in the LingApp system with S3 support
43 lines (30 loc) • 845 B
Markdown
A Mongoose model for file management with S3 integration.
```bash
npm install lingapp-file
```
```typescript
import { File } from 'lingapp-file';
// Create a new file
const file = await File.create({
size: 1024,
name: 'example.pdf',
key: 'path/to/file.pdf',
url: 'https://example.com/file.pdf'
});
// Find a file
const file = await File.findById(id);
// Delete a file (will also delete from S3 if STORAGE_TYPE is 's3')
await File.deleteOne({ _id: id });
```
The following environment variables are required when using S3 storage:
- `STORAGE_TYPE`: Set to 's3' to enable S3 integration
- `AWS_REGION`: Your AWS region
- `AWS_ACCESS_KEY_ID`: Your AWS access key
- `AWS_SECRET_ACCESS_KEY`: Your AWS secret key
- `BUCKET_NAME`: Your S3 bucket name
MIT