@@ -12,17 +12,16 @@ const FALLBACK_TYPE = "image/jpeg";
12
12
* @returns Array of MediaSet objects.
13
13
*/
14
14
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
+ } ) ;
20
20
21
- return attachments ;
22
- } catch ( error ) {
23
- console . error ( error ) ;
24
- return [ ] ;
25
- }
21
+ return attachments ;
22
+ } catch {
23
+ return [ ] ;
24
+ }
26
25
} ;
27
26
28
27
/**
@@ -32,16 +31,16 @@ const uploadToIPFS = async (data: File[]): Promise<StorageNodeResponse[]> => {
32
31
* @returns MediaSet object or null if the upload fails.
33
32
*/
34
33
export const uploadFileToIPFS = async (
35
- file : File
34
+ file : File ,
36
35
) : 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 ] ;
40
39
41
- return { mimeType, uri } ;
42
- } catch {
43
- return { mimeType : "" , uri : "" } ;
44
- }
40
+ return { mimeType, uri } ;
41
+ } catch {
42
+ return { mimeType : "" , uri : "" } ;
43
+ }
45
44
} ;
46
45
47
46
export default uploadToIPFS ;
0 commit comments