summaryrefslogtreecommitdiff
path: root/client/faceAnalysis/faceAnalysis.actions.js
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2019-01-13 18:08:49 +0100
committerJules Laplace <julescarbon@gmail.com>2019-01-13 18:08:49 +0100
commit6710b9f7f223acd01ac82171d9f9f4eb577f5885 (patch)
treee8328f43f107e5c5dbef2aeb8b2746239a44508a /client/faceAnalysis/faceAnalysis.actions.js
parent47b6ae0f8ad2f49692222bb0c800e7ba1eb4b94b (diff)
serializing image failed, writing to tmp file instead
Diffstat (limited to 'client/faceAnalysis/faceAnalysis.actions.js')
-rw-r--r--client/faceAnalysis/faceAnalysis.actions.js39
1 files changed, 21 insertions, 18 deletions
diff --git a/client/faceAnalysis/faceAnalysis.actions.js b/client/faceAnalysis/faceAnalysis.actions.js
index 6a318b5d..860d3292 100644
--- a/client/faceAnalysis/faceAnalysis.actions.js
+++ b/client/faceAnalysis/faceAnalysis.actions.js
@@ -8,7 +8,7 @@ import { get, post } from '../util'
// urls
const url = {
- upload: () => process.env.API_HOST + '/task/upload/sleep',
+ upload: () => process.env.API_HOST + '/task/upload/blur',
}
export const publicUrl = {
}
@@ -45,22 +45,6 @@ export const updateOptions = opt => dispatch => {
// API functions
-export const upload = (payload, file) => dispatch => {
- // const { options } = store.getState().faceAnalysis
- const tag = 'task'
- const fd = new FormData()
- fd.append('query_img', file)
- // fd.append('limit', options.perPage)
- // if (!query) {
- dispatch(loading(tag))
- // }
- post(url.upload(payload.dataset), fd)
- .then(data => {
- dispatch(loaded(tag, data))
- })
- .catch(err => dispatch(error(tag, err)))
-}
-
// task polling
const POLL_DELAY = 500
@@ -68,12 +52,31 @@ let pollTimeout = null
export const poll = (payload, taskURL) => dispatch => {
clearTimeout(pollTimeout)
+ console.log('polling...')
get(taskURL)
.then(data => {
+ console.log('poll', data)
dispatch(polled(data))
- if (!data.complete) {
+ if (data.state !== 'error' && data.state !== 'complete') {
pollTimeout = setTimeout(() => poll(payload, taskURL), POLL_DELAY)
}
})
.catch(err => dispatch(error('result', err)))
}
+
+export const upload = (payload, file) => dispatch => {
+ const tag = 'task'
+ const fd = new FormData()
+ fd.append('query_img', file)
+ dispatch(loading(tag))
+ post(url.upload(), fd)
+ .then(data => {
+ console.log('loaded!', tag, data)
+ dispatch(loaded(tag, data))
+ const { result, taskURL } = data
+ if (result && taskURL) {
+ poll(payload, taskURL)(dispatch)
+ }
+ })
+ .catch(err => dispatch(error(tag, err)))
+}