-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(jaen-pages): switch from ipfs to osg
Due to availability issues, all functionalities related to IPFS have been rewritten to use OSG (open-storage-gateway: http://osg.snek.at).
- Loading branch information
Showing
9 changed files
with
113 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
export const upload = async ( | ||
payload: object | Blob | File, | ||
backend: 'IPFS' | 'OSG' = 'OSG' | ||
) => { | ||
if (backend === 'IPFS') { | ||
const ipfsClient = await import('ipfs-http-client') | ||
|
||
const ipfs = ipfsClient.create({ | ||
host: 'ipfs.infura.io', | ||
port: 5001, | ||
protocol: 'https' | ||
}) | ||
|
||
const {cid} = await ipfs.add( | ||
typeof payload === 'object' ? JSON.stringify(payload) : payload | ||
) | ||
return `https://cloudflare-ipfs.com/ipfs/${cid.toString()}` | ||
} else { | ||
const url = 'https://osg.snek.at/storage' | ||
|
||
const formData = new FormData() | ||
|
||
// payload to blob | ||
if (payload instanceof Blob || payload instanceof File) { | ||
formData.append('file', payload) | ||
} else { | ||
formData.append( | ||
'file', | ||
new File([JSON.stringify(payload)], 'jaen-index.json', { | ||
type: 'application/json' | ||
}) | ||
) | ||
} | ||
|
||
const resp = await fetch(url, { | ||
body: formData, | ||
method: 'POST' | ||
}) | ||
|
||
const json = await resp.json() | ||
|
||
return `${url}/${json.file_id}` | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4686,7 +4686,7 @@ | |
dependencies: | ||
lottie-web "^5.7.12" | ||
|
||
"@snek-at/[email protected]", "@snek-at/snek-finder@^1.0.0-beta.16": | ||
"@snek-at/[email protected]": | ||
version "1.0.0-beta.16" | ||
resolved "https://registry.yarnpkg.com/@snek-at/snek-finder/-/snek-finder-1.0.0-beta.16.tgz#aea560a4b530633a7e34ca94cc4a86e8622f8bed" | ||
integrity sha512-BVUFcxMmmZ2HAm+gs5EFhv0AaO7Bix8x8uhcchh8PNnxX/EnilCn6EBDiygj7KVDRqZMec2I5nqL9pcP0Gvo+Q== | ||
|
@@ -4713,6 +4713,33 @@ | |
react-table "^7.7.0" | ||
react-zoom-pan-pinch "^2.1.3" | ||
|
||
"@snek-at/snek-finder@^1.0.0-beta.17": | ||
version "1.0.0-beta.17" | ||
resolved "https://registry.yarnpkg.com/@snek-at/snek-finder/-/snek-finder-1.0.0-beta.17.tgz#b60d0d9bfd044fbe8127df7bd030bc4e830c5805" | ||
integrity sha512-DKcdJGFmg+DEPOxb7UApxkpH1e3xouOu5djd/2CPnlFjb+4Je3FulMSpGIF4tM4mLDUPHVl39p9ITBMrXW6Yfg== | ||
dependencies: | ||
"@chakra-ui/icons" "^1.0.14" | ||
"@chakra-ui/react" "^1.6.6" | ||
"@emotion/react" "^11" | ||
"@emotion/styled" "^11" | ||
"@react-icons/all-files" "^4.1.0" | ||
"@react-pdf-viewer/core" "^2.7.1" | ||
"@react-pdf-viewer/default-layout" "^2.7.1" | ||
"@react-pdf-viewer/print" "^2.7.1" | ||
"@toast-ui/react-image-editor" "^3.15.0" | ||
filerobot-image-editor "^3.12.17" | ||
framer-motion "^4" | ||
immutability-helper "^3.1.1" | ||
ipfs-http-client "^52.0.0" | ||
pdf2pic "^2.1.4" | ||
react "^17.0.2" | ||
react-dnd "^14.0.2" | ||
react-dnd-html5-backend "^14.0.0" | ||
react-dropzone "^11.3.4" | ||
react-pdf "^5.3.2" | ||
react-table "^7.7.0" | ||
react-zoom-pan-pinch "^2.1.3" | ||
|
||
"@snek-at/storybook-addon-chakra-ui@^1.0.0-beta.2": | ||
version "1.0.0-beta.2" | ||
resolved "https://registry.yarnpkg.com/@snek-at/storybook-addon-chakra-ui/-/storybook-addon-chakra-ui-1.0.0-beta.2.tgz#4d73b00cf051a5161c842d37560b8f976fd15dd8" | ||
|