From 1813207772b57dc888fe9d3902852453fe7f62e2 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Wed, 18 Sep 2019 18:38:02 +0200 Subject: [PATCH] fix gateway url ping --- client/src/hooks/use-ipfs-api.tsx | 2 +- .../index.module.scss => Ipfs.module.scss} | 2 +- .../{Ipfs/index.test.tsx => Ipfs.test.tsx} | 2 +- .../Publish/Files/{Ipfs/index.tsx => Ipfs.tsx} | 18 +++++++++--------- 4 files changed, 12 insertions(+), 12 deletions(-) rename client/src/routes/Publish/Files/{Ipfs/index.module.scss => Ipfs.module.scss} (96%) rename client/src/routes/Publish/Files/{Ipfs/index.test.tsx => Ipfs.test.tsx} (97%) rename client/src/routes/Publish/Files/{Ipfs/index.tsx => Ipfs.tsx} (85%) diff --git a/client/src/hooks/use-ipfs-api.tsx b/client/src/hooks/use-ipfs-api.tsx index 40fb24f..f15b277 100644 --- a/client/src/hooks/use-ipfs-api.tsx +++ b/client/src/hooks/use-ipfs-api.tsx @@ -7,7 +7,7 @@ let ipfs: any = null let ipfsMessage = '' let ipfsVersion = '' -interface IpfsConfig { +export interface IpfsConfig { host: string port: string protocol: string diff --git a/client/src/routes/Publish/Files/Ipfs/index.module.scss b/client/src/routes/Publish/Files/Ipfs.module.scss similarity index 96% rename from client/src/routes/Publish/Files/Ipfs/index.module.scss rename to client/src/routes/Publish/Files/Ipfs.module.scss index 7412d24..d71a6b3 100644 --- a/client/src/routes/Publish/Files/Ipfs/index.module.scss +++ b/client/src/routes/Publish/Files/Ipfs.module.scss @@ -1,4 +1,4 @@ -@import '../../../../styles/variables'; +@import '../../../styles/variables'; .ipfsForm { margin-top: $spacer / 2; diff --git a/client/src/routes/Publish/Files/Ipfs/index.test.tsx b/client/src/routes/Publish/Files/Ipfs.test.tsx similarity index 97% rename from client/src/routes/Publish/Files/Ipfs/index.test.tsx rename to client/src/routes/Publish/Files/Ipfs.test.tsx index 398686e..791a79b 100644 --- a/client/src/routes/Publish/Files/Ipfs/index.test.tsx +++ b/client/src/routes/Publish/Files/Ipfs.test.tsx @@ -1,6 +1,6 @@ import React from 'react' import { render, fireEvent } from '@testing-library/react' -import Ipfs from '.' +import Ipfs from './Ipfs' const addFile = jest.fn() diff --git a/client/src/routes/Publish/Files/Ipfs/index.tsx b/client/src/routes/Publish/Files/Ipfs.tsx similarity index 85% rename from client/src/routes/Publish/Files/Ipfs/index.tsx rename to client/src/routes/Publish/Files/Ipfs.tsx index c6f48b1..bd29ce8 100644 --- a/client/src/routes/Publish/Files/Ipfs/index.tsx +++ b/client/src/routes/Publish/Files/Ipfs.tsx @@ -1,14 +1,14 @@ /* eslint-disable no-console */ import React, { useState, useEffect } from 'react' -import useIpfsApi from '../../../../hooks/use-ipfs-api' -import Label from '../../../../components/atoms/Form/Label' -import Spinner from '../../../../components/atoms/Spinner' -import Dropzone from '../../../../components/molecules/Dropzone' -import { formatBytes, pingUrl, readFileAsync } from '../../../../utils/utils' -import { ipfsGatewayUri } from '../../../../config' -import styles from './index.module.scss' +import useIpfsApi, { IpfsConfig } from '../../../hooks/use-ipfs-api' +import Label from '../../../components/atoms/Form/Label' +import Spinner from '../../../components/atoms/Spinner' +import Dropzone from '../../../components/molecules/Dropzone' +import { formatBytes, pingUrl, readFileAsync } from '../../../utils/utils' +import { ipfsGatewayUri } from '../../../config' +import styles from './Ipfs.module.scss' -const config = { +const config: IpfsConfig = { host: 'ipfs.infura.io', port: '5001', protocol: 'https' @@ -76,7 +76,7 @@ export default function Ipfs({ addFile }: { addFile(url: string): void }) { // Ping gateway url to make it globally available, // but store native url in DDO. - const urlGateway = `${ipfsGatewayUri}/ipfs/${cid}` + const urlGateway = `${ipfsGatewayUri}/ipfs/${cid}/${name}` const url = `ipfs://${cid}/${name}` setMessage('Checking IPFS gateway URL')