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)) {
|
2019-11-02 16:21:11 +01:00
|
|
|
case String.name:
|
2019-10-30 13:28:32 +01:00
|
|
|
params.append("file",this.file)
|
2019-10-02 19:20:37 +02:00
|
|
|
break
|
2019-11-02 16:21:11 +01:00
|
|
|
case File.name:
|
2019-10-02 19:20:37 +02:00
|
|
|
var base64=btoa(await getTextFromUploadedFileAsync(this.file))
|
2019-10-30 13:28:32 +01:00
|
|
|
params.append("fileBase64",base64);
|
2019-10-02 19:20:37 +02:00
|
|
|
break
|
|
|
|
}
|
2019-10-30 13:28:32 +01:00
|
|
|
if ([...params].length>0){
|
2019-11-02 15:00:11 +01:00
|
|
|
return urlbase+"?"+params.toString()
|
2019-10-30 13:28:32 +01:00
|
|
|
}
|
|
|
|
else{
|
|
|
|
return urlbase
|
|
|
|
}
|
|
|
|
|
2019-09-30 09:53:07 +02:00
|
|
|
}
|
|
|
|
}
|