10
0
mirror of https://github.com/LCPQ/QUESTDB_website.git synced 2024-11-05 05:33:55 +01:00
QUESTDB_website/static/js/websiteFile.js

26 lines
553 B
JavaScript
Raw Normal View History

2019-09-30 09:53:07 +02:00
class websiteFile{
2019-10-02 19:20:37 +02:00
constructor(file){
this.file=file
2019-09-30 09:53:07 +02:00
}
2019-10-02 19:20:37 +02:00
async getViewerURL(){
2019-11-02 15:00:11 +01:00
var params=new URLSearchParams()
2019-10-02 19:20:37 +02:00
var urlbase="/view"
switch (trueTypeOf(this.file)) {
case String.name:
params.append("file",this.file)
2019-10-02 19:20:37 +02:00
break
case File.name:
2019-10-02 19:20:37 +02:00
var base64=btoa(await getTextFromUploadedFileAsync(this.file))
params.append("fileBase64",base64);
2019-10-02 19:20:37 +02:00
break
}
if ([...params].length>0){
2019-11-02 15:00:11 +01:00
return urlbase+"?"+params.toString()
}
else{
return urlbase
}
2019-09-30 09:53:07 +02:00
}
}