Bulk-Move für Objects
Mehrfachauswahl in der Objekttabelle (Checkboxen + Alle-auswählen), neues Popup zum Verschieben in einen anderen Bucket, Move via Copy+Delete gegen die bestehende S3-Schnittstelle. sigv4 kann jetzt zusätzliche Header signieren (x-amz-copy-source), sonst nix am Backend angefasst wie gewünscht.
This commit is contained in:
@@ -43,5 +43,49 @@ export function useS3Client() {
|
||||
await $fetch(`/api${encodeCanonicalPath(path)}`, { method: 'DELETE', headers })
|
||||
}
|
||||
|
||||
return { listBuckets, listObjects, downloadObject, getObjectText, uploadObject, deleteObject }
|
||||
async function copyObject(sourceBucket: string, sourceKey: string, destBucket: string, destKey: string): Promise<void> {
|
||||
const destPath = `/${destBucket}/${destKey}`
|
||||
const copySource = encodeCanonicalPath(`/${sourceBucket}/${sourceKey}`)
|
||||
const headers = await signS3Put(destPath, config.public.s3AccessKey, config.public.s3SecretKey, {
|
||||
'x-amz-copy-source': copySource,
|
||||
})
|
||||
await $fetch(`/api${encodeCanonicalPath(destPath)}`, {
|
||||
method: 'PUT',
|
||||
headers: { ...headers, 'x-amz-copy-source': copySource },
|
||||
})
|
||||
}
|
||||
|
||||
async function moveObject(sourceBucket: string, key: string, destBucket: string): Promise<void> {
|
||||
await copyObject(sourceBucket, key, destBucket, key)
|
||||
await deleteObject(sourceBucket, key)
|
||||
}
|
||||
|
||||
async function moveObjects(
|
||||
sourceBucket: string,
|
||||
keys: string[],
|
||||
destBucket: string,
|
||||
): Promise<{ key: string; error: unknown }[]> {
|
||||
const failures: { key: string; error: unknown }[] = []
|
||||
for (const key of keys) {
|
||||
try {
|
||||
await moveObject(sourceBucket, key, destBucket)
|
||||
}
|
||||
catch (error) {
|
||||
failures.push({ key, error })
|
||||
}
|
||||
}
|
||||
return failures
|
||||
}
|
||||
|
||||
return {
|
||||
listBuckets,
|
||||
listObjects,
|
||||
downloadObject,
|
||||
getObjectText,
|
||||
uploadObject,
|
||||
deleteObject,
|
||||
copyObject,
|
||||
moveObject,
|
||||
moveObjects,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user