mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-22 22:49:45 +01:00
feat: send metadata along with download request
This commit is contained in:
@@ -8,28 +8,29 @@ export default class FileStorage {
|
||||
this._queue = [];
|
||||
}
|
||||
|
||||
async downloadFile(groupId, hash, chunkSize) {
|
||||
const url = `${hosts.API_HOST}/s3?name=${hash}`;
|
||||
async downloadFile(groupId, filename, chunkSize, metadata) {
|
||||
const url = `${hosts.API_HOST}/s3?name=${filename}`;
|
||||
const token = await this.tokenManager.getAccessToken();
|
||||
const { execute, cancel } = this.fs.downloadFile(hash, {
|
||||
const { execute, cancel } = this.fs.downloadFile(filename, {
|
||||
metadata,
|
||||
url,
|
||||
chunkSize,
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
this._queue.push({ groupId, hash, cancel, type: "download" });
|
||||
this._queue.push({ groupId, filename, cancel, type: "download" });
|
||||
const result = await execute();
|
||||
this._deleteOp(groupId, "download");
|
||||
return result;
|
||||
}
|
||||
|
||||
async uploadFile(groupId, hash) {
|
||||
async uploadFile(groupId, filename) {
|
||||
const token = await this.tokenManager.getAccessToken();
|
||||
const url = `${hosts.API_HOST}/s3?name=${hash}`;
|
||||
const { execute, cancel } = this.fs.uploadFile(hash, {
|
||||
const url = `${hosts.API_HOST}/s3?name=${filename}`;
|
||||
const { execute, cancel } = this.fs.uploadFile(filename, {
|
||||
url,
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
this._queue.push({ groupId, hash, cancel, type: "upload" });
|
||||
this._queue.push({ groupId, filename, cancel, type: "upload" });
|
||||
const result = await execute();
|
||||
this._deleteOp(groupId, "upload");
|
||||
return result;
|
||||
@@ -65,7 +66,7 @@ export default class FileStorage {
|
||||
if (localOnly) return await this.fs.deleteFile(filename);
|
||||
|
||||
const token = await this.tokenManager.getToken();
|
||||
const url = `${hosts.API_HOST}/s3?name=${hash}`;
|
||||
const url = `${hosts.API_HOST}/s3?name=${filename}`;
|
||||
return await this.fs.deleteFile(filename, {
|
||||
url,
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
|
||||
Reference in New Issue
Block a user