Skip to content

Commit

Permalink
fix invalid url
Browse files Browse the repository at this point in the history
  • Loading branch information
yuetloo committed Jun 18, 2024
1 parent 6a52152 commit b7b3c53
Show file tree
Hide file tree
Showing 2 changed files with 611 additions and 6 deletions.
12 changes: 6 additions & 6 deletions contracts/tasks/runners/exportImages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ import fs from 'fs'

/**
* Download the IPFS file with the ipfsHash to the output directory
* @param baseUrl IPFS gateway base url
* @param gateway IPFS gateway url
* @param ipfsHash IPFS hash of the file to download
* @param outputDir The directory to store the downloaded file
*/
async function download({
baseUrl,
gateway,
ipfsHash,
outputDir,
}: {
baseUrl: string
gateway: string
ipfsHash: string
outputDir: string
}) {
const url = new URL(ipfsHash, baseUrl)
const url = new URL(`ipfs/${ipfsHash}`, gateway)
const req = new FetchRequest(url.href)
const res = await req.send()
if (res.hasBody()) {
Expand Down Expand Up @@ -61,12 +61,12 @@ task('export-images', 'Export project logo images')

for (let i = 0; i < images.length; i++) {
await download({
baseUrl: gateway,
gateway,
ipfsHash: images[i].bannerImageHash,
outputDir,
})
await download({
baseUrl: gateway,
gateway,
ipfsHash: images[i].thumbnailImageHash,
outputDir,
})
Expand Down
Loading

0 comments on commit b7b3c53

Please sign in to comment.