diff options
author | Monika Hedman <monika_hedman@brown.edu> | 2019-03-09 20:38:07 -0500 |
---|---|---|
committer | Monika Hedman <monika_hedman@brown.edu> | 2019-03-09 20:38:07 -0500 |
commit | 2bf52426b853dfa6ae9c24c2f1e5d493c524139a (patch) | |
tree | 45fc24106c57587c0bd14137d1dda401240573ac | |
parent | 0b134f758aaf5e382a354596976161415b0fb5ea (diff) |
audio and video upload working
-rw-r--r-- | src/client/views/collections/CollectionViewBase.tsx | 53 |
1 files changed, 18 insertions, 35 deletions
diff --git a/src/client/views/collections/CollectionViewBase.tsx b/src/client/views/collections/CollectionViewBase.tsx index 440ff87ca..38271e7bf 100644 --- a/src/client/views/collections/CollectionViewBase.tsx +++ b/src/client/views/collections/CollectionViewBase.tsx @@ -98,7 +98,9 @@ export class CollectionViewBase extends React.Component<SubCollectionViewProps> }) } - if (item.kind == "file" && item.type.indexOf("image") !== -1) { + let type = item.type + console.log(type) + if (item.kind == "file") { let fReader = new FileReader() let file = item.getAsFile(); let formData = new FormData() @@ -118,53 +120,34 @@ export class CollectionViewBase extends React.Component<SubCollectionViewProps> json.map((file: any) => { let path = window.location.origin + file runInAction(() => { + var doc: any; - - - var img = Documents.ImageDocument(path, { ...options, nativeWidth: 300, width: 300, }) - - - - - + if (type.indexOf("image") !== -1) { + doc = Documents.ImageDocument(path, { ...options, nativeWidth: 300, width: 300, }) + } + if (type.indexOf("video") !== -1) { + doc = Documents.VideoDocument(path, { ...options, nativeWidth: 300, width: 300, }) + } + if (type.indexOf("audio") !== -1) { + doc = Documents.AudioDocument(path, { ...options, nativeWidth: 300, width: 300, }) + } let docs = that.props.Document.GetT(KeyStore.Data, ListField); if (docs != FieldWaiting) { if (!docs) { docs = new ListField<Document>(); that.props.Document.Set(KeyStore.Data, docs) } - docs.Data.push(img); + if (doc) { + docs.Data.push(doc); + } } }) }) }) - // fReader.addEventListener("load", action("drop", () => { - // if (fReader.result) { - // let form = request.post(upload).form(); - // form.append('file', fReader.result); - // // let url = "" + fReader.result; - // // let doc = Documents.ImageDocument(url, options) - // // let docs = that.props.Document.GetT(KeyStore.Data, ListField); - // // if (docs != FieldWaiting) { - // // if (!docs) { - // // docs = new ListField<Document>(); - // // that.props.Document.Set(KeyStore.Data, docs) - // // } - // // docs.Data.push(doc); - // // } - // } - // }), false) - // if (file) { - // fReader.readAsBinaryString(file) - // } + + } - // request.post(upload, { - // body: { - // test: "DEAR GOD PLEASE SEND! (NEITHER)", - // }, - // json: true - // }) } } } |