Merge branch 'main' of http://211.119.124.110:3000/xit-app/adds-fo.git into main
commit
4efe44c4d6
@ -1,38 +1,16 @@
|
|||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* 서버의 파일 정보로 javascript File 객체 생성
|
* 서버의 파일 정보로 javascript File 객체 생성
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
async function fnCreateFileFromFileInfo(fileInfo) {
|
async function fnCreateFileFromFileInfo(fileInfo){
|
||||||
|
|
||||||
try {
|
let response = await fetch(fileInfo.URL);
|
||||||
let response = await fetch(fileInfo.URL);
|
let data = await response.blob();
|
||||||
|
let metadata = {
|
||||||
|
type: fileInfo.MIME_TYPE
|
||||||
|
};
|
||||||
|
let file = new File([data], fileInfo.FILE_NM, metadata);
|
||||||
|
file.id = fileInfo.FILE_ID;
|
||||||
|
file.url = fileInfo.URL;
|
||||||
|
|
||||||
if (!response.ok) {
|
return new Promise(resolve => { resolve(file); });
|
||||||
//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 metadata = {
|
|
||||||
type: fileInfo.MIME_TYPE
|
|
||||||
};
|
|
||||||
let file = new File([data], fileInfo.FILE_NM, metadata);
|
|
||||||
file.id = fileInfo.FILE_ID;
|
|
||||||
file.url = fileInfo.URL;
|
|
||||||
|
|
||||||
return new Promise(resolve => {
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue