mirror of
https://github.com/oceanprotocol/commons.git
synced 2023-03-15 18:03:00 +01:00
update file metadata structure
This commit is contained in:
parent
3a26cc39e0
commit
bfc0e6548a
@ -8,14 +8,10 @@ const AssetModel = {
|
|||||||
name: null,
|
name: null,
|
||||||
description: null,
|
description: null,
|
||||||
dateCreated: null,
|
dateCreated: null,
|
||||||
size: null,
|
|
||||||
author: null,
|
author: null,
|
||||||
type: '',
|
type: '',
|
||||||
license: null,
|
license: null,
|
||||||
copyrightHolder: null,
|
copyrightHolder: null,
|
||||||
encoding: null,
|
|
||||||
compression: null,
|
|
||||||
contentType: null,
|
|
||||||
workExample: null,
|
workExample: null,
|
||||||
files: [],
|
files: [],
|
||||||
categories: [],
|
categories: [],
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import React, { Component } from 'react'
|
import React, { Component } from 'react'
|
||||||
import { Logger } from '@oceanprotocol/squid'
|
import { Logger } from '@oceanprotocol/squid'
|
||||||
import queryString from 'query-string'
|
|
||||||
import Route from '../../components/templates/Route'
|
import Route from '../../components/templates/Route'
|
||||||
import Spinner from '../../components/atoms/Spinner'
|
import Spinner from '../../components/atoms/Spinner'
|
||||||
import { User } from '../../context/User'
|
import { User } from '../../context/User'
|
||||||
@ -37,8 +36,14 @@ export default class Details extends Component<DetailsProps, DetailsState> {
|
|||||||
accessService.serviceDefinitionId,
|
accessService.serviceDefinitionId,
|
||||||
account[0]
|
account[0]
|
||||||
)
|
)
|
||||||
const folder = ""
|
const folder = ''
|
||||||
const path = await this.context.ocean.assets.consume(agreementId, ddo.id, accessService.serviceDefinitionId, account[0], folder)
|
const path = await this.context.ocean.assets.consume(
|
||||||
|
agreementId,
|
||||||
|
ddo.id,
|
||||||
|
accessService.serviceDefinitionId,
|
||||||
|
account[0],
|
||||||
|
folder
|
||||||
|
)
|
||||||
Logger.log('path', path)
|
Logger.log('path', path)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Logger.log('error', e)
|
Logger.log('error', e)
|
||||||
|
@ -8,10 +8,15 @@ const Item = ({ item, removeItem }: { item: any; removeItem: any }) => (
|
|||||||
<div className={styles.details}>
|
<div className={styles.details}>
|
||||||
<span>url: {item.found ? 'confirmed' : 'unconfirmed'}</span>
|
<span>url: {item.found ? 'confirmed' : 'unconfirmed'}</span>
|
||||||
<span>
|
<span>
|
||||||
size:
|
{item.found && item.contentLength
|
||||||
{item.found && item.size ? filesize(item.size) : 'unknown'}
|
? filesize(item.contentLength)
|
||||||
|
: 'unknown size'}
|
||||||
|
</span>
|
||||||
|
<span>
|
||||||
|
{item.found && item.contentType
|
||||||
|
? item.contentType
|
||||||
|
: 'unknown type'}
|
||||||
</span>
|
</span>
|
||||||
<span>type: {item.found && item.type ? item.type : 'unknown'}</span>
|
|
||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
|
@ -8,8 +8,19 @@ import styles from './index.module.scss'
|
|||||||
|
|
||||||
import { serviceHost, servicePort, serviceScheme } from '../../../config'
|
import { serviceHost, servicePort, serviceScheme } from '../../../config'
|
||||||
|
|
||||||
|
interface File {
|
||||||
|
url: string
|
||||||
|
checksum?: string
|
||||||
|
checksumType?: string
|
||||||
|
contentLength?: string
|
||||||
|
contentType?: string
|
||||||
|
resourceId?: string
|
||||||
|
encoding?: string
|
||||||
|
compression?: string
|
||||||
|
}
|
||||||
|
|
||||||
interface FilesProps {
|
interface FilesProps {
|
||||||
files: any[]
|
files: File[]
|
||||||
placeholder: string
|
placeholder: string
|
||||||
help?: string
|
help?: string
|
||||||
name: string
|
name: string
|
||||||
@ -20,6 +31,24 @@ interface FilesStates {
|
|||||||
isFormShown: boolean
|
isFormShown: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getFileCompression = async (contentType: string) => {
|
||||||
|
// TODO: add all the possible archive & compression MIME types
|
||||||
|
if (
|
||||||
|
contentType === 'application/zip' ||
|
||||||
|
contentType === 'application/gzip' ||
|
||||||
|
contentType === 'application/x-lzma' ||
|
||||||
|
contentType === 'application/x-xz' ||
|
||||||
|
contentType === 'application/x-tar' ||
|
||||||
|
contentType === 'application/x-bzip2' ||
|
||||||
|
contentType === 'application/x-7z-compressed'
|
||||||
|
) {
|
||||||
|
const contentTypeSplit = contentType.split('/')
|
||||||
|
return contentTypeSplit[1]
|
||||||
|
} else {
|
||||||
|
return 'none'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default class Files extends PureComponent<FilesProps, FilesStates> {
|
export default class Files extends PureComponent<FilesProps, FilesStates> {
|
||||||
public state: FilesStates = {
|
public state: FilesStates = {
|
||||||
isFormShown: false
|
isFormShown: false
|
||||||
@ -46,8 +75,9 @@ export default class Files extends PureComponent<FilesProps, FilesStates> {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
res = await response.json()
|
res = await response.json()
|
||||||
file.size = res.result.contentLength
|
file.contentLength = res.result.contentLength
|
||||||
file.type = res.result.contentType
|
file.contentType = res.result.contentType
|
||||||
|
file.compression = await getFileCompression(file.contentType)
|
||||||
file.found = res.result.found
|
file.found = res.result.found
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// error
|
// error
|
||||||
|
@ -258,10 +258,6 @@ class Publish extends Component<{}, PublishState> {
|
|||||||
price: this.state.price,
|
price: this.state.price,
|
||||||
type: this.state.type,
|
type: this.state.type,
|
||||||
categories: [this.state.categories],
|
categories: [this.state.categories],
|
||||||
size: '',
|
|
||||||
encoding: '',
|
|
||||||
compression: undefined,
|
|
||||||
contentType: '',
|
|
||||||
workExample: undefined,
|
workExample: undefined,
|
||||||
inLanguage: undefined,
|
inLanguage: undefined,
|
||||||
tags: ''
|
tags: ''
|
||||||
|
Loading…
Reference in New Issue
Block a user