1
0
mirror of https://github.com/oceanprotocol/commons.git synced 2023-03-15 18:03:00 +01:00

contentLength as string

This commit is contained in:
Matthias Kretschmann 2019-11-12 13:27:23 +01:00
parent ac5c66f0e9
commit 6282dbb5fc
Signed by: m
GPG Key ID: 606EEEF3C479A91F
6 changed files with 9 additions and 13 deletions

View File

@ -14,7 +14,7 @@ const file = {
index: 0,
url: 'https://hello.com',
contentType: 'application/x-zip',
contentLength: 100
contentLength: '100'
}
const ddo = ({

View File

@ -119,11 +119,9 @@ export default class AssetFile extends PureComponent<
<ul key={index} className={styles.file}>
{contentType || contentLength ? (
<>
<li>{cleanupContentType(contentType)}</li>
<li>
{contentType && cleanupContentType(contentType)}
</li>
<li>
{contentLength && contentLength > 0
{contentLength && contentLength !== '0'
? filesize(contentLength)
: ''}
</li>

View File

@ -8,7 +8,7 @@ describe('Item', () => {
url: 'https://hello.com/hello.zip',
found: true,
contentType: 'application/zip',
contentLength: 10
contentLength: '10'
}
const { container } = render(
<Item item={item} removeItem={() => null} />
@ -21,7 +21,7 @@ describe('Item', () => {
url: 'https://hello.com/hello.zip',
found: false,
contentType: '',
contentLength: 10
contentLength: '10'
}
const { container } = render(
<Item item={item} removeItem={() => null} />

View File

@ -11,7 +11,7 @@ const Item = ({
url: string
found: boolean
contentType: string
contentLength: number
contentLength: string
}
removeFile(): void
}) => (

View File

@ -14,7 +14,7 @@ const files = [
url: 'https://hello.com',
checksum: 'cccccc',
checksumType: 'MD5',
contentLength: 100,
contentLength: '100',
contentType: 'application/zip',
resourceId: 'xxx',
encoding: 'UTF-8',

View File

@ -42,9 +42,7 @@ export class UrlCheckRouter {
result.found = true
if (headers['content-length']) {
result.contentLength = parseInt(
headers['content-length']
) // convert to number
result.contentLength = headers['content-length']
}
// sometimes servers send content-range header,
@ -54,7 +52,7 @@ export class UrlCheckRouter {
!headers['content-length']
) {
const size = headers['content-range'].split('/')[1]
result.contentLength = parseInt(size) // convert to number
result.contentLength = size
}
if (headers['content-type']) {