add asset edit, rename/move and replace

Signed-off-by: RonniSkansing <rskansing@gmail.com>
This commit is contained in:
RonniSkansing committed 2026-10-06 21:24:19 +02:00
1 parent 04afdc1712
commit 8580530c34
7 files changed
+964 -38

No files matched your search

+54
View File
@@ -362,6 +362,60 @@ export class API {
});
},
/**
* Get an asset's content in base64 and whether it is editable as text
*
* @param {string} id
* @returns {Promise<ApiResponse>}
*/
getContent: async (id) => {
return await getJSON(this.getPath(`/asset/${id}/content`));
},
/**
* Save an asset's text content
*
* @param {string} id
* @param {string} content
* @returns {Promise<ApiResponse>}
*/
saveContent: async (id, content) => {
return await putJSON(this.getPath(`/asset/${id}/content`), {
content: content
});
},
/**
* Rename or move an asset to a new path within its context
*
* @param {string} id
* @param {string} path
* @returns {Promise<ApiResponse>}
*/
move: async (id, path) => {
return await patchJSON(this.getPath(`/asset/${id}/move`), {
path: path
});
},
/**
* Replace an asset's file with an uploaded file
*
* @param {string} id
* @param {FormData} data form data with a 'file' field
* @returns {Promise<ApiResponse>}
*/
replaceFile: async (id, data) => {
const res = await fetch(this.getPath(`/asset/${id}/file`), {
method: 'POST',
// content-type is set automatically by the browser
body: data
});
const body = await res.json();
return newResponse(body.success, res.status, body.error, body.data);
},
/**
* Get all assets for a domain using pagination.
*