2019-11-06 20:36:28 +00:00
|
|
|
// License: LGPL-3.0-or-later
|
|
|
|
const flyd = require('flyd')
|
|
|
|
const R = require('ramda')
|
2020-09-01 23:16:17 +00:00
|
|
|
const activestorage = require('../../common/activestorage')
|
2019-11-06 20:36:28 +00:00
|
|
|
|
|
|
|
// Pass in a stream of Input Nodes with type file
|
|
|
|
// Make a post request to our server to start the import
|
|
|
|
// Will create a backgrounded job and email the user when
|
|
|
|
// completed
|
|
|
|
// Returns a stream of {uri: 'uri of uploaded file on s3', formData: 'original form data'}
|
2020-09-01 23:16:17 +00:00
|
|
|
const uploadFile = (controllerUrl) => {
|
|
|
|
return R.curry(input => {
|
|
|
|
const $stream = flyd.stream()
|
|
|
|
activestorage.uploadFile(controllerUrl, input.files[0]).then((blob) => $stream(blob))
|
|
|
|
return $stream;
|
|
|
|
})
|
|
|
|
}
|
2019-11-06 20:36:28 +00:00
|
|
|
|
|
|
|
module.exports = uploadFile
|
|
|
|
|