Skip to content
This repository was archived by the owner on Aug 30, 2022. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions src/core/uploaders/pinata-uploader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,14 @@ export class PinataUploader implements IStorageUpload {
if (!res.ok) {
throw new UploadError("Failed to upload files to IPFS");
}

const cid = body.IpfsHash;
if (!cid) {
throw new UploadError("Failed to upload files to IPFS");
}

return {
cid: body.IpfsHash,
cid,
fileNames,
};
} else {
Expand All @@ -81,8 +87,17 @@ export class PinataUploader implements IStorageUpload {
xhr.setRequestHeader("Authorization", `Bearer ${token}`);

xhr.onloadend = () => {
if (xhr.status !== 200) {
throw new UploadError("Failed to upload files to IPFS");
}

const cid = JSON.parse(xhr.responseText).IpfsHash;
if (!cid) {
throw new UploadError("Failed to upload files to IPFS");
}

resolve({
cid: JSON.parse(xhr.responseText).IpfsHash,
cid,
fileNames,
});
};
Expand Down