Only store the fileId with b2.
It's smaller.
This commit is contained in:
parent
1c5e4061f5
commit
9bbd580fe3
@ -46,6 +46,7 @@ const POSTRedirect = url => (req, res) => {
|
||||
};
|
||||
|
||||
app.post('/api/v1/get_upload_url', POSTRedirect('/b2api/v1/b2_get_upload_url'));
|
||||
app.post('/api/v1/get_file_info', POSTRedirect('/b2api/v1/b2_get_file_info'));
|
||||
app.post('/api/v1/remove_file', POSTRedirect('/b2api/v1/b2_delete_file_version'));
|
||||
|
||||
module.exports = {
|
||||
|
||||
@ -72,22 +72,25 @@ export const B2Adapter = function(b2apikey, b2secret, b2bucket) {
|
||||
}
|
||||
|
||||
return PouchDBAttachmentProxy({
|
||||
getFn: async function getAttachment(obj) {
|
||||
const res = await fetch(await downloadUrl(obj.fileId), {
|
||||
getFn: async function getAttachment(id) {
|
||||
const res = await fetch(await downloadUrl(id), {
|
||||
headers: await headers()
|
||||
});
|
||||
|
||||
return res.blob();
|
||||
},
|
||||
remove: async function removeAttachment(obj) {
|
||||
remove: async function removeAttachment(id) {
|
||||
const s = await session();
|
||||
return fetch('/api/v1/remove_file', {
|
||||
const res = await fetch('/api/v1/get_file_info', {
|
||||
headers: await headers(),
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
fileName: obj.fileName,
|
||||
fileId: obj.fileId
|
||||
})
|
||||
body: JSON.stringify({ fileId: id })
|
||||
});
|
||||
const { fileName, fileId } = await res.json();
|
||||
return await fetch('/api/v1/remove_file', {
|
||||
headers: await headers(),
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ fileName, fileId })
|
||||
});
|
||||
},
|
||||
save: async function saveAttachment(blob) {
|
||||
@ -104,11 +107,8 @@ export const B2Adapter = function(b2apikey, b2secret, b2bucket) {
|
||||
}),
|
||||
body: blob
|
||||
});
|
||||
const data = await res.json();
|
||||
return {
|
||||
fileId: data.fileId,
|
||||
fileName: data.fileName
|
||||
};
|
||||
const { fileId } = await res.json();
|
||||
return fileId;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user