mirror of
https://github.com/logos-storage/logos-storage-marketplace-ui.git
synced 2026-01-05 23:13:08 +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,
|
file: File,
|
||||||
onProgress?: (loaded: number, total: number) => void
|
onProgress?: (loaded: number, total: number) => void
|
||||||
): UploadResponse {
|
): 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);
|
const { result, abort } = super.upload(file, onProgress);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
abort,
|
abort,
|
||||||
result: result.then((safe) => {
|
result: result.then((safe) => {
|
||||||
if (!safe.error) {
|
if (!safe.error) {
|
||||||
return WebStorage.set(safe.data, {
|
return FilesStorage.set(safe.data, {
|
||||||
type: file.type,
|
mimetype: file.type,
|
||||||
name: file.name,
|
name: file.name,
|
||||||
|
uploadedAt: new Date().toJSON(),
|
||||||
}).then(() => safe);
|
}).then(() => safe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user