fixed error on metadata 404
This commit is contained in:
parent
76175d61af
commit
bace117ada
2 changed files with 7 additions and 2 deletions
|
@ -6,7 +6,7 @@ export default class FileReceiver extends Nanobus {
|
||||||
super('FileReceiver');
|
super('FileReceiver');
|
||||||
this.secretKeyPromise = window.crypto.subtle.importKey(
|
this.secretKeyPromise = window.crypto.subtle.importKey(
|
||||||
'raw',
|
'raw',
|
||||||
b64ToArray(file.key),
|
b64ToArray(file.secretKey),
|
||||||
'HKDF',
|
'HKDF',
|
||||||
false,
|
false,
|
||||||
['deriveKey']
|
['deriveKey']
|
||||||
|
@ -122,6 +122,9 @@ export default class FileReceiver extends Nanobus {
|
||||||
const xhr = new XMLHttpRequest();
|
const xhr = new XMLHttpRequest();
|
||||||
xhr.onreadystatechange = () => {
|
xhr.onreadystatechange = () => {
|
||||||
if (xhr.readyState === XMLHttpRequest.DONE) {
|
if (xhr.readyState === XMLHttpRequest.DONE) {
|
||||||
|
if (xhr.status === 404) {
|
||||||
|
return reject(new Error(xhr.status));
|
||||||
|
}
|
||||||
const nonce = xhr.getResponseHeader('WWW-Authenticate').split(' ')[1];
|
const nonce = xhr.getResponseHeader('WWW-Authenticate').split(' ')[1];
|
||||||
this.file.nonce = nonce;
|
this.file.nonce = nonce;
|
||||||
if (xhr.status === 200) {
|
if (xhr.status === 200) {
|
||||||
|
@ -172,6 +175,8 @@ export default class FileReceiver extends Nanobus {
|
||||||
this.file.iv = meta.iv;
|
this.file.iv = meta.iv;
|
||||||
this.file.size = data.size;
|
this.file.size = data.size;
|
||||||
this.file.ttl = data.ttl;
|
this.file.ttl = data.ttl;
|
||||||
|
this.file.dlimit = data.dlimit;
|
||||||
|
this.file.dtotal = data.dtotal;
|
||||||
this.state = 'ready';
|
this.state = 'ready';
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.state = 'invalid';
|
this.state = 'invalid';
|
||||||
|
|
|
@ -21,7 +21,7 @@ module.exports = function(state, emit) {
|
||||||
return notFound(state, emit);
|
return notFound(state, emit);
|
||||||
}
|
}
|
||||||
state.fileInfo.id = state.params.id;
|
state.fileInfo.id = state.params.id;
|
||||||
state.fileInfo.key = state.params.key;
|
state.fileInfo.secretKey = state.params.key;
|
||||||
const fileInfo = state.fileInfo;
|
const fileInfo = state.fileInfo;
|
||||||
const size = fileInfo.size
|
const size = fileInfo.size
|
||||||
? state.translate('downloadFileSize', { size: bytes(fileInfo.size) })
|
? state.translate('downloadFileSize', { size: bytes(fileInfo.size) })
|
||||||
|
|
Loading…
Reference in a new issue