/**
* Move a S3 file from one path to the other within the same bucket
*
*/
export async function main(
workspace: string,
src_file_key: string | undefined,
dest_file_key: string | undefined
) {
const url = new URL(
`${BASE_URL}/api/w/${workspace}/job_helpers/move_s3_file`
);
for (const [k, v] of [
["src_file_key", src_file_key],
["dest_file_key", dest_file_key],
]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Bearer " + WM_TOKEN,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 238 days ago