rem
This commit is contained in:
parent
1e3bfeb987
commit
edca2a9bba
@ -7,18 +7,19 @@ let client = new HttpClient(serviceProto, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
async function upload() {
|
async function upload() {
|
||||||
// Load File
|
let file = (document.querySelector('input[type=file]') as HTMLInputElement).files?.[0];
|
||||||
let file = document.querySelector('input[type=file]') as HTMLInputElement;
|
if (!file) {
|
||||||
if (!file.files || !file.files[0]) {
|
|
||||||
alert('Please select a file')
|
alert('Please select a file')
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let fileData = await loadFile(file.files[0]);
|
|
||||||
|
// Load file as Uint8Array
|
||||||
|
let fileData = await loadFile(file);
|
||||||
|
|
||||||
// Upload
|
// Upload
|
||||||
let ret = await client.callApi('Upload', {
|
let ret = await client.callApi('Upload', {
|
||||||
fileData: fileData,
|
fileData: fileData,
|
||||||
fileName: file.files[0].name
|
fileName: file.name
|
||||||
});
|
});
|
||||||
|
|
||||||
// Error
|
// Error
|
||||||
@ -29,7 +30,6 @@ async function upload() {
|
|||||||
|
|
||||||
// Succ
|
// Succ
|
||||||
document.querySelector('ol')!.innerHTML += `<li><a href="${ret.res.url}" target="_blank">${ret.res.url}</a></li>\n`;
|
document.querySelector('ol')!.innerHTML += `<li><a href="${ret.res.url}" target="_blank">${ret.res.url}</a></li>\n`;
|
||||||
file.value = '';
|
|
||||||
alert('Upload successfully!')
|
alert('Upload successfully!')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user