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:
2025-11-20 13:20:19 +00:00
parent 0c631383e1
commit 5889396134
15 changed files with 2644 additions and 1562 deletions

View File

@@ -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