Add setApiUrlPrefix and use it in the android version.
This commit is contained in:
parent
74d8a12c07
commit
ae4b8cf0d3
4 changed files with 36 additions and 14 deletions
|
@ -1,7 +1,7 @@
|
|||
import Nanobus from 'nanobus';
|
||||
import Keychain from './keychain';
|
||||
import { delay, bytes, streamToArrayBuffer } from './utils';
|
||||
import { downloadFile, metadata } from './api';
|
||||
import { downloadFile, metadata, getApiUrl } from './api';
|
||||
import { blobStream } from './streams';
|
||||
import Zip from './zip';
|
||||
|
||||
|
@ -145,14 +145,18 @@ export default class FileReceiver extends Nanobus {
|
|||
onprogress(0);
|
||||
|
||||
if (noSave) {
|
||||
const res = await fetch(`/api/download/${this.fileInfo.id}`);
|
||||
const res = await fetch(getApiUrl(`/api/download/${this.fileInfo.id}`));
|
||||
if (res.status !== 200) {
|
||||
throw new Error(res.status);
|
||||
}
|
||||
} else {
|
||||
const downloadUrl = `${location.protocol}//${
|
||||
location.host
|
||||
}/api/download/${this.fileInfo.id}`;
|
||||
const downloadPath = `/api/download/${this.fileInfo.id}`;
|
||||
let downloadUrl = getApiUrl(downloadPath);
|
||||
if (downloadUrl === downloadPath) {
|
||||
downloadUrl = `${location.protocol}//${location.host}/api/download/${
|
||||
this.fileInfo.id
|
||||
}`;
|
||||
}
|
||||
const a = document.createElement('a');
|
||||
a.href = downloadUrl;
|
||||
document.body.appendChild(a);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue