development #1
@@ -139,6 +139,11 @@
|
||||
|
||||
|
||||
if (!response.ok) {
|
||||
if (response.status == 400) {
|
||||
let json_res = await response.json()
|
||||
alert(json_res['msg'])
|
||||
return;
|
||||
}
|
||||
throw new Error(`Fehlgeschlagen: ${response.status}`)
|
||||
} else {
|
||||
setTimeout(() => {window.location.reload()}, 500)
|
||||
|
||||
@@ -11,10 +11,20 @@ export async function PUT({ request }) {
|
||||
// Vorgang
|
||||
let vorgang = request.url.split('/').at(-1)
|
||||
|
||||
// copy
|
||||
// prepare copy, incl. check if new name exists already
|
||||
let old_name = data["old_name"]
|
||||
let src_full_path = `/tatort/${vorgang}/${old_name}`
|
||||
let new_name = `${vorgang}/${data["new_name"]}`
|
||||
|
||||
try {
|
||||
let file_stats = await client.statObject('tatort', new_name)
|
||||
return json({ msg: 'Die Datei existiert bereits.' }, { status: 400 })
|
||||
} catch (error) {
|
||||
// continue operation
|
||||
console.log('continue operation')
|
||||
}
|
||||
|
||||
// actual copy operation
|
||||
await client.copyObject('tatort', new_name, src_full_path)
|
||||
|
||||
// delete
|
||||
|
||||
Reference in New Issue
Block a user