Cleanup of old code, moved Node class, many improvements on file handling
This commit is contained in:
parent
65f8cd14a7
commit
16992db6b1
19 changed files with 485 additions and 3281 deletions
|
|
@ -23,7 +23,6 @@ export class API {
|
|||
throw new Error(json.Error, { cause: { type: 'application', application: json, } })
|
||||
|
||||
return json
|
||||
|
||||
} catch (err) {
|
||||
// Catch any other errors from fetch.
|
||||
throw new Error(err.message, { cause: { type: 'http', error: err, } })
|
||||
|
|
@ -31,21 +30,21 @@ export class API {
|
|||
}
|
||||
|
||||
// Sends a block of binary data to server.
|
||||
static async upload(uuid, data, sentBytes, file) {
|
||||
static async upload(uuid, data, sentBytes, metadata) {
|
||||
try {
|
||||
const path = `/sync/file/upload/${uuid}`
|
||||
const headers = {
|
||||
'X-File-Sent-Bytes': sentBytes,
|
||||
'X-File-Total-Bytes': file.size,
|
||||
'X-File-Total-Bytes': metadata.size,
|
||||
}
|
||||
|
||||
// Metadata is needed for the database.
|
||||
// No need to send it every block.
|
||||
if (sentBytes === 0) {
|
||||
headers['X-File-Name'] = file.name
|
||||
headers['X-File-Size'] = file.size
|
||||
headers['X-File-Type'] = file.type
|
||||
headers['X-File-Modified'] = file.lastModified
|
||||
headers['X-File-Name'] = metadata.name
|
||||
headers['X-File-Size'] = metadata.size
|
||||
headers['X-File-Type'] = metadata.type
|
||||
headers['X-File-Modified'] = metadata.modified
|
||||
}
|
||||
|
||||
// Authentication is done with a bearer token.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue