BREAKING CHANGE(core): Make API strict-by-default: remove *Strict variants, throw on not-found/exists conflicts, add explicit exists() methods, update docs/tests and bump deps
This commit is contained in:
21
readme.md
21
readme.md
@@ -88,8 +88,8 @@ console.log('🗑️ Bucket removed');
|
||||
```typescript
|
||||
const bucket = await smartBucket.getBucketByName('my-bucket');
|
||||
|
||||
// Simple file upload
|
||||
await bucket.fastPut({
|
||||
// Simple file upload (returns File object)
|
||||
const file = await bucket.fastPut({
|
||||
path: 'documents/report.pdf',
|
||||
contents: Buffer.from('Your file content here')
|
||||
});
|
||||
@@ -100,12 +100,23 @@ await bucket.fastPut({
|
||||
contents: 'Buy milk\nCall mom\nRule the world'
|
||||
});
|
||||
|
||||
// Strict upload (returns File object)
|
||||
const uploadedFile = await bucket.fastPutStrict({
|
||||
// Upload with overwrite control
|
||||
const uploadedFile = await bucket.fastPut({
|
||||
path: 'images/logo.png',
|
||||
contents: imageBuffer,
|
||||
overwrite: true // Optional: control overwrite behavior
|
||||
overwrite: true // Set to true to replace existing files
|
||||
});
|
||||
|
||||
// Error handling: fastPut throws if file exists and overwrite is false
|
||||
try {
|
||||
await bucket.fastPut({
|
||||
path: 'existing-file.txt',
|
||||
contents: 'new content'
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Upload failed:', error.message);
|
||||
// Error: Object already exists at path 'existing-file.txt' in bucket 'my-bucket'. Set overwrite:true to replace it.
|
||||
}
|
||||
```
|
||||
|
||||
#### Download Files
|
||||
|
||||
Reference in New Issue
Block a user