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,
|
||||
description: null,
|
||||
dateCreated: null,
|
||||
size: null,
|
||||
author: null,
|
||||
type: '',
|
||||
license: null,
|
||||
copyrightHolder: null,
|
||||
encoding: null,
|
||||
compression: null,
|
||||
contentType: null,
|
||||
workExample: null,
|
||||
files: [],
|
||||
categories: [],
|
||||
|
@ -1,6 +1,5 @@
|
||||
import React, { Component } from 'react'
|
||||
import { Logger } from '@oceanprotocol/squid'
|
||||
import queryString from 'query-string'
|
||||
import Route from '../../components/templates/Route'
|
||||
import Spinner from '../../components/atoms/Spinner'
|
||||
import { User } from '../../context/User'
|
||||
@ -37,8 +36,14 @@ export default class Details extends Component<DetailsProps, DetailsState> {
|
||||
accessService.serviceDefinitionId,
|
||||
account[0]
|
||||
)
|
||||
const folder = ""
|
||||
const path = await this.context.ocean.assets.consume(agreementId, ddo.id, accessService.serviceDefinitionId, account[0], folder)
|
||||
const folder = ''
|
||||
const path = await this.context.ocean.assets.consume(
|
||||
agreementId,
|
||||
ddo.id,
|
||||
accessService.serviceDefinitionId,
|
||||
account[0],
|
||||
folder
|
||||
)
|
||||
Logger.log('path', path)
|
||||
} catch (e) {
|
||||
Logger.log('error', e)
|
||||
|
@ -8,10 +8,15 @@ const Item = ({ item, removeItem }: { item: any; removeItem: any }) => (
|
||||
<div className={styles.details}>
|
||||
<span>url: {item.found ? 'confirmed' : 'unconfirmed'}</span>
|
||||
<span>
|
||||
size:
|
||||
{item.found && item.size ? filesize(item.size) : 'unknown'}
|
||||
{item.found && item.contentLength
|
||||
? filesize(item.contentLength)
|
||||
: 'unknown size'}
|
||||
</span>
|
||||
<span>
|
||||
{item.found && item.contentType
|
||||
? item.contentType
|
||||
: 'unknown type'}
|
||||
</span>
|
||||
<span>type: {item.found && item.type ? item.type : 'unknown'}</span>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
|
@ -8,8 +8,19 @@ import styles from './index.module.scss'
|
||||
|
||||
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 {
|
||||
files: any[]
|
||||
files: File[]
|
||||
placeholder: string
|
||||
help?: string
|
||||
name: string
|
||||
@ -20,6 +31,24 @@ interface FilesStates {
|
||||
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> {
|
||||
public state: FilesStates = {
|
||||
isFormShown: false
|
||||
@ -46,8 +75,9 @@ export default class Files extends PureComponent<FilesProps, FilesStates> {
|
||||
}
|
||||
)
|
||||
res = await response.json()
|
||||
file.size = res.result.contentLength
|
||||
file.type = res.result.contentType
|
||||
file.contentLength = res.result.contentLength
|
||||
file.contentType = res.result.contentType
|
||||
file.compression = await getFileCompression(file.contentType)
|
||||
file.found = res.result.found
|
||||
} catch (error) {
|
||||
// error
|
||||
|
@ -258,10 +258,6 @@ class Publish extends Component<{}, PublishState> {
|
||||
price: this.state.price,
|
||||
type: this.state.type,
|
||||
categories: [this.state.categories],
|
||||
size: '',
|
||||
encoding: '',
|
||||
compression: undefined,
|
||||
contentType: '',
|
||||
workExample: undefined,
|
||||
inLanguage: undefined,
|
||||
tags: ''
|
||||
|
Loading…
Reference in New Issue
Block a user