Skip to content

Commit 5833e69

Browse files
committed
Migrate to Lens v3
1 parent 6150224 commit 5833e69

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

apps/web/src/helpers/uploadToIPFS.ts

+17-18
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,16 @@ const FALLBACK_TYPE = "image/jpeg";
1212
* @returns Array of MediaSet objects.
1313
*/
1414
const uploadToIPFS = async (data: File[]): Promise<StorageNodeResponse[]> => {
15-
try {
16-
const { files } = await storageClient.uploadFolder(data);
17-
const attachments = files.map(({ uri }, index) => {
18-
return { mimeType: data[index].type || FALLBACK_TYPE, uri };
19-
});
15+
try {
16+
const { files } = await storageClient.uploadFolder(data);
17+
const attachments = files.map(({ gatewayUrl }, index) => {
18+
return { mimeType: data[index].type || FALLBACK_TYPE, uri: gatewayUrl };
19+
});
2020

21-
return attachments;
22-
} catch (error) {
23-
console.error(error);
24-
return [];
25-
}
21+
return attachments;
22+
} catch {
23+
return [];
24+
}
2625
};
2726

2827
/**
@@ -32,16 +31,16 @@ const uploadToIPFS = async (data: File[]): Promise<StorageNodeResponse[]> => {
3231
* @returns MediaSet object or null if the upload fails.
3332
*/
3433
export const uploadFileToIPFS = async (
35-
file: File
34+
file: File,
3635
): Promise<StorageNodeResponse> => {
37-
try {
38-
const response = await uploadToIPFS([file]);
39-
const { uri, mimeType } = response[0];
36+
try {
37+
const response = await uploadToIPFS([file]);
38+
const { uri, mimeType } = response[0];
4039

41-
return { mimeType, uri };
42-
} catch {
43-
return { mimeType: "", uri: "" };
44-
}
40+
return { mimeType, uri };
41+
} catch {
42+
return { mimeType: "", uri: "" };
43+
}
4544
};
4645

4746
export default uploadToIPFS;

0 commit comments

Comments
 (0)