Skip to content

Commit

Permalink
add file storage API calls to federalistApi
Browse files Browse the repository at this point in the history
  • Loading branch information
sknep committed Feb 25, 2025
1 parent 376fc40 commit ecae38e
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions frontend/util/federalistApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,4 +365,55 @@ export default {
fetchReportData(id, subPage) {
return request(`tasks/${id}/report/${subPage || ''}`);
},

fetchPublicFiles(fileStorageId, path = '') {
return request(`file-storage/${fileStorageId}${path}`, {
method: 'GET',
});
},

createPublicDirectory(fileStorageId, parent = '', name) {
return request(`file-storage/${fileStorageId}/directory`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ parent: parent, name: name }),
});
},

uploadPublicFile(fileStorageId, parent = '', fileName) {
return request(`file-storage/${fileStorageId}/directory`, {
method: 'POST',
body: JSON.stringify({ parent: parent, name: fileName }),
// Do not set content type header
});
},

deletePublicFile(fileStorageId, fileId) {
return request(`file-storage/${fileStorageId}/file/${fileId}`, {
method: 'DELETE',
// not sure if we need the content type here, could be copypasta
headers: { 'Content-Type': 'application/json' },
});
},

deletePublicDirectory(fileStorageId, fileId) {
return request(`file-storage/${fileStorageId}/file/${fileId}`, {
method: 'DELETE',
headers: { 'Content-Type': 'application/json' },
});
},

fetchPublicFileHistory(fileStorageId, fileId) {
return request(`file-storage/${fileStorageId}/user-actions/${fileId}`, {
method: 'GET',
headers: { 'Content-Type': 'application/json' },
});
},

fetchAllPublicFilesHistory(fileStorageId) {
return request(`file-storage/${fileStorageId}/user-actions/}`, {
method: 'GET',
headers: { 'Content-Type': 'application/json' },
});
}
};

0 comments on commit ecae38e

Please sign in to comment.