From 82dd17057b08ade7c1bb22ab5f4a3526568e116b Mon Sep 17 00:00:00 2001 From: Preschian Febryantara Date: Thu, 20 Jun 2024 19:22:13 +0700 Subject: [PATCH 1/2] revert: redirect to nftstorage --- services/image/src/routes/ipfs.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/services/image/src/routes/ipfs.ts b/services/image/src/routes/ipfs.ts index ee32a40..982cfa5 100644 --- a/services/image/src/routes/ipfs.ts +++ b/services/image/src/routes/ipfs.ts @@ -114,8 +114,6 @@ app.get('/*', async (c) => { // 4. upload object to r2 // ---------------------------------------- console.log('step 4', url.toString()) - const ipfsNftstorage = toIpfsGw(url.toString(), 'w3s') - console.log('ipfsNftstorage', ipfsNftstorage) const status = await fetchIPFS({ path: fullPath, }) @@ -138,7 +136,14 @@ app.get('/*', async (c) => { ) } - return c.redirect(ipfsNftstorage) + // 5. return object from r2 + // ---------------------------------------- + console.log('step 5') + const newObject = await c.env.MY_BUCKET.get(objectName) + + if (newObject !== null) { + return renderR2Object(newObject, newObject?.httpMetadata?.contentType) + } }) app.delete('/*', async (c) => { From 681af485e284dd2d103130f14ebe12101b074c74 Mon Sep 17 00:00:00 2001 From: Preschian Febryantara Date: Fri, 21 Jun 2024 14:09:33 +0700 Subject: [PATCH 2/2] test(type-endpoint.test.ts): update expected blob length in 'type-endpoint - 200 - image - original' test --- services/image/src/tests/type-endpoint.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/image/src/tests/type-endpoint.test.ts b/services/image/src/tests/type-endpoint.test.ts index 7866bf4..693e466 100644 --- a/services/image/src/tests/type-endpoint.test.ts +++ b/services/image/src/tests/type-endpoint.test.ts @@ -88,7 +88,7 @@ test('type-endpoint - 200 - image - original', async () => { expect(data).toMatchInlineSnapshot(` Blob { Symbol(kHandle): Blob {}, - Symbol(kLength): 86783, + Symbol(kLength): 631349, Symbol(kType): "image/png", } `)