-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Description
I'm still getting acquainted with managing s3 buckets programaticaly so bare with me...
I've written the following function using this lib:
/**
* Syncs a directory to an S3 bucket.
*
* @param syncFrom The local directory path to sync from.
* @param syncTo The S3 bucket path to sync to.
* @returns A Promise that resolves when the sync is complete.
*/
const syncDirectoryToS3 = async (syncFrom: string, syncTo: string): Promise<void> => {
// Sync wrapper for S3 Client
// www.npmjs.com/package/s3-sync-client
const {sync} = new S3SyncClient({client: new S3Client(AWS_CREDS)});
// Command input for content type
const commandInput = (input: any) => ({ContentType: mime.lookup(input.Key) || 'text/html'});
// Event listener for progress updates
const monitor = new TransferMonitor().on('progress', progress => progressUpdate(progress));
// Run sync command and update on progress
await sync(syncFrom, syncTo, {del: true, commandInput, monitor});
console.log(`\nTransfer complete: ${syncTo} is now synced with files from ${syncFrom}`);
};
I have del: true right there in the call to sync() at the end, but for some reason when I delete files locally and sync, they are still in the s3 bucket... anyone see anything overtly with this function?
How I tested:
- Create folder
foolocally and touchfile1.txtfile2.txt - Run sync command above
- List contents of
foo - Delete
file1.txtlocally - Run sync command above
- List contents of
foo
file1.txt is still in the s3 bucket.
Metadata
Metadata
Assignees
Labels
No labels