mirror of
https://github.com/logos-storage/logos-storage-marketplace-ui.git
synced 2026-01-03 22:13:13 +00:00
Fix metadata in proxy object
This commit is contained in:
parent
a9832f81a9
commit
c685d13e05
47
src/proxy.ts
47
src/proxy.ts
@ -16,15 +16,58 @@ class CodexDataMock extends CodexData {
|
||||
file: File,
|
||||
onProgress?: (loaded: number, total: number) => void
|
||||
): UploadResponse {
|
||||
// const url = CodexSdk.url() + "/api/codex/v1/data";
|
||||
|
||||
// const xhr = new XMLHttpRequest();
|
||||
|
||||
// const promise = new Promise<SafeValue<string>>((resolve) => {
|
||||
// xhr.upload.onprogress = (evt) => {
|
||||
// if (evt.lengthComputable) {
|
||||
// onProgress?.(evt.loaded, evt.total);
|
||||
// }
|
||||
// };
|
||||
|
||||
// xhr.open("POST", url, true);
|
||||
// xhr.setRequestHeader("Content-Disposition", "attachment; filename=\"" + file.name + "\"")
|
||||
// xhr.send(file);
|
||||
|
||||
// xhr.onload = function () {
|
||||
// if (xhr.status != 200) {
|
||||
// resolve({
|
||||
// error: true,
|
||||
// data: new CodexError(xhr.responseText, {
|
||||
// code: xhr.status,
|
||||
// }),
|
||||
// });
|
||||
// } else {
|
||||
// resolve({ error: false, data: xhr.response });
|
||||
// }
|
||||
// };
|
||||
|
||||
// xhr.onerror = function () {
|
||||
// resolve({
|
||||
// error: true,
|
||||
// data: new CodexError("Something went wrong during the file upload."),
|
||||
// });
|
||||
// };
|
||||
// });
|
||||
|
||||
// return {
|
||||
// result: promise,
|
||||
// abort: () => {
|
||||
// xhr.abort();
|
||||
// },
|
||||
// };
|
||||
const { result, abort } = super.upload(file, onProgress);
|
||||
|
||||
return {
|
||||
abort,
|
||||
result: result.then((safe) => {
|
||||
if (!safe.error) {
|
||||
return WebStorage.set(safe.data, {
|
||||
type: file.type,
|
||||
return FilesStorage.set(safe.data, {
|
||||
mimetype: file.type,
|
||||
name: file.name,
|
||||
uploadedAt: new Date().toJSON(),
|
||||
}).then(() => safe);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user