2018-08-08 01:15:34 +02:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-11-30 21:46:22 +01:00
|
|
|
// I M P O R T
|
2018-08-08 01:15:34 +02:00
|
|
|
|
2018-11-30 21:46:22 +01:00
|
|
|
import got from "got";
|
2018-11-21 22:57:43 +01:00
|
|
|
|
|
|
|
// U T I L
|
|
|
|
|
2018-11-30 21:46:22 +01:00
|
|
|
const queryUrl = process.env.NODE_ENV === "development" ?
|
|
|
|
"http://localhost:5200/image" :
|
|
|
|
`https://${process.env.DAEMON_URL}/image`;
|
2018-08-08 01:15:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// E X P O R T
|
|
|
|
|
2018-11-30 21:46:22 +01:00
|
|
|
export default async(imageSource) => {
|
2018-11-21 22:57:43 +01:00
|
|
|
const options = {
|
2018-08-16 22:43:49 +02:00
|
|
|
body: {
|
|
|
|
authorization: process.env.LBRY_DAEMON_ACCESS_TOKEN,
|
|
|
|
image: imageSource
|
2018-08-08 01:15:34 +02:00
|
|
|
},
|
2018-11-30 21:46:22 +01:00
|
|
|
json: true
|
2018-11-21 22:57:43 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
try {
|
2018-11-30 21:46:22 +01:00
|
|
|
const response = await got.post(queryUrl, options);
|
2018-11-21 22:57:43 +01:00
|
|
|
return response.body; // eslint-disable-line padding-line-between-statements
|
|
|
|
} catch (error) {
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
};
|