|
|
@ -3,21 +3,8 @@
|
|
|
|
**************************************************************************/
|
|
|
|
**************************************************************************/
|
|
|
|
async function fnCreateFileFromFileInfo(fileInfo){
|
|
|
|
async function fnCreateFileFromFileInfo(fileInfo){
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
let response = await fetch(fileInfo.URL);
|
|
|
|
let response = await fetch(fileInfo.URL);
|
|
|
|
|
|
|
|
|
|
|
|
if (!response.ok) {
|
|
|
|
|
|
|
|
//throw new Error(`HTTP error! status: ${response.status}`);
|
|
|
|
|
|
|
|
let file = new File([], fileInfo.FILE_NM, metadata);
|
|
|
|
|
|
|
|
file.id = fileInfo.FILE_ID;
|
|
|
|
|
|
|
|
file.url = fileInfo.URL;
|
|
|
|
|
|
|
|
return new Promise(resolve => {
|
|
|
|
|
|
|
|
resolve(file);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let data = await response.blob();
|
|
|
|
let data = await response.blob();
|
|
|
|
|
|
|
|
|
|
|
|
let metadata = {
|
|
|
|
let metadata = {
|
|
|
|
type: fileInfo.MIME_TYPE
|
|
|
|
type: fileInfo.MIME_TYPE
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -25,14 +12,5 @@ async function fnCreateFileFromFileInfo(fileInfo) {
|
|
|
|
file.id = fileInfo.FILE_ID;
|
|
|
|
file.id = fileInfo.FILE_ID;
|
|
|
|
file.url = fileInfo.URL;
|
|
|
|
file.url = fileInfo.URL;
|
|
|
|
|
|
|
|
|
|
|
|
return new Promise(resolve => {
|
|
|
|
return new Promise(resolve => { resolve(file); });
|
|
|
|
resolve(file);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
|
|
console.error('Fetch error:', error);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Handle the error appropriately, e.g., return a default value or rethrow
|
|
|
|
|
|
|
|
// Here, we'll return null to indicate failure
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|