diff --git a/api/ipfs/utils.py b/api/ipfs/utils.py index 2d4309e..fc76c3f 100644 --- a/api/ipfs/utils.py +++ b/api/ipfs/utils.py @@ -18,11 +18,13 @@ def pin_image(imageFile, imageName): suffix = imageName.split('.').pop() try: - with NamedTemporaryFile(suffix=f".{suffix}", delete=True) as temp_file: - # convert uploaded file to temp file in order to upload. - temp_file.write(imageFile.read()) + with NamedTemporaryFile(suffix=f".{suffix}", delete=True) as temp_file: + with open(temp_file.name, 'wb+') as pin_file: + for chunk in imageFile.chunks(): + pin_file.write(chunk) + pin_response = pinata.pin_file_to_ipfs( - temp_file.name, + pin_file.name, '', save_absolute_paths=False ) diff --git a/frontend/src/components/Dashboard/Org/OrgForm.js b/frontend/src/components/Dashboard/Org/OrgForm.js index f9da067..a787f59 100644 --- a/frontend/src/components/Dashboard/Org/OrgForm.js +++ b/frontend/src/components/Dashboard/Org/OrgForm.js @@ -96,10 +96,12 @@ const OrgForm = () => { } } - // Custom image upload. - const onCustomImageUpload = (image) => { - setIsCustomImage(true); - setOrgImage(image); + // Custom image upload. If image gets set to null then get new generative. + const onCustomImageUpload = async (image) => { + setIsCustomImage(image ? true : false); + let customImage = image ? + image : await getPFPImage(firstCharOfName.current); + setOrgImage(image ?? customImage); } // Get a generated image for the org. @@ -117,12 +119,13 @@ const OrgForm = () => { // Pin the org image to IPFS. const pinImage = async (image) => { - const response = await postIPFSImage(image) - if (response.error) { + const response = await postIPFSImage(image); + + if (response?.error) { setError({ - label: 'Could not upload image to IPFS', + label: "Error uploading image to IPFS", message: response.error - }); + }) return; } diff --git a/frontend/src/components/Dashboard/Sidebar/OrgSidebar.js b/frontend/src/components/Dashboard/Sidebar/OrgSidebar.js index 5279803..27e0824 100644 --- a/frontend/src/components/Dashboard/Sidebar/OrgSidebar.js +++ b/frontend/src/components/Dashboard/Sidebar/OrgSidebar.js @@ -64,8 +64,6 @@ const OrgSidebar = ({ address }) => { openConnectModal() }, [openConnectModal, address]) - console.log('ensName', ensName, ensAvatar, ensFetched) - return (