max-mapper / max-mapper/abstract-blob-store
move/rename method?
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 275
- Forks
- 25
- PR merge metrics
- No merged PRs in 30d
Description
Would be nice if there was a standardised move or rename method. Most backends support that natively and those that don't support it through a bit more of manual work (e.g. on s3, one has to copy the file and then delete the original). I've been monkey patching fs-store and s3-store to do this :/:
const stores = {
fs: () => {
const fsPath = path.join(__dirname, '../.tmp');
const store = fsblobs(fsPath);
store.absolutePath = (relPath) => {
return path.join(fsPath, relPath);
};
store.move = (oldKey, newKey, cb) => {
const oldPath = store.absolutePath(oldKey);
const newPath = store.absolutePath(newKey);
return fs.rename(oldPath, newPath, cb);
};
return store;
},
s3: () => {
const client = new aws.S3({
accessKeyId: config.aws.key,
secretAccessKey: config.aws.secret,
});
const bucket = config.aws.s3.bucket;
const store = s3blobs({ client, bucket });
store.move = (oldKey, newKey) => {
const copySource = bucket + '/' + oldKey;
const params = {
'CopySource': copySource,
'Bucket': bucket,
'Key': newKey,
};
client.copyObject(params, (err, data) => {
if (err) return cb(err);
client.deleteObject({
'Bucket': bucket,
'Key': oldKey,
}, (_err) => {
if (_err) return cb(_err);
cb();
});
});
});
};
return store;
},
};
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the repository's abstract interface and test suite, then compare the fs-store and s3-store move examples in the issue. Determine how a standard move or rename operation should be represented across backends, including the copy-and-delete case, and add coverage showing the operation is complete.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100