Image uploads work and this closes #135

This commit is contained in:
ポール ウェッブ 2018-08-16 15:43:49 -05:00
parent 7fce2c7873
commit 801068f200
5 changed files with 18 additions and 20 deletions

View file

@ -5,7 +5,7 @@
module.exports = exports = { module.exports = exports = {
ga: "UA-60403362-1", ga: "UA-60403362-1",
github: { github: {
branch: "new", branch: "master",
linkText: "Edit this page on GitHub", linkText: "Edit this page on GitHub",
repo: "lbryio/lbry.tech" repo: "lbryio/lbry.tech"
}, },

View file

@ -58,17 +58,17 @@ module.exports = exports = (data, socket) => {
body.bid = 0.001; // Hardcoded publish amount body.bid = 0.001; // Hardcoded publish amount
body.description = dataDetails.description; body.description = dataDetails.description;
body.file_path = process.env.LBRY_DAEMON_IMAGES_PATH + dataDetails.file_path; // TODO: Fix the internal image path in daemon (original comment, check to see if still true) body.file_path = dataDetails.file_path; // just base64 string
body.language = dataDetails.language; body.language = dataDetails.language;
body.license = dataDetails.license; body.license = dataDetails.license;
body.name = dataDetails.name.replace(/\s/g, "") + randomString(10); body.name = dataDetails.name.replace(/\s/g, "") + randomString(10);
body.nsfw = dataDetails.nsfw; body.nsfw = dataDetails.nsfw;
body.title = dataDetails.title; body.title = dataDetails.title;
// TODO: Forget all this and upload to spee.ch
return uploadImage(body.file_path).then(uploadResponse => { return uploadImage(body.file_path).then(uploadResponse => {
if (uploadResponse.status !== "ok") return; // if (uploadResponse.status !== "ok") return;
// console.log("————— RESPONSE");
// console.log(uploadResponse);
body.file_path = uploadResponse.filename; body.file_path = uploadResponse.filename;
body.filename = uploadResponse.filename; body.filename = uploadResponse.filename;
@ -77,8 +77,8 @@ module.exports = exports = (data, socket) => {
// https://github.com/lbryio/lbry.tech/blob/legacy/content/.vuepress/components/Tour/Step2.vue // https://github.com/lbryio/lbry.tech/blob/legacy/content/.vuepress/components/Tour/Step2.vue
// https://github.com/lbryio/lbry.tech/blob/legacy/server.js // https://github.com/lbryio/lbry.tech/blob/legacy/server.js
}).catch(uploadError => { }).catch(uploadError => {
// component.isLoading = false; // console.log("————— ERROR");
// component.jsonData = JSON.stringify(uploadError, null, " "); // console.log(uploadError);
socket.send(JSON.stringify({ socket.send(JSON.stringify({
"details": "Image upload failed", "details": "Image upload failed",

View file

@ -10,19 +10,17 @@ const request = require("request-promise-native");
// E X P O R T // E X P O R T
module.exports = exports = imageSource => new Promise((resolve, reject) => { module.exports = exports = imageSource => new Promise((resolve, reject) => { // eslint-disable-line
request({ return request({
body: imageSource, body: {
headers: { authorization: process.env.LBRY_DAEMON_ACCESS_TOKEN,
"Content-Type": "text/plain" image: imageSource
}, },
method: "PUT", json: true,
qs: { method: "POST",
access_token: process.env.LBRY_DAEMON_ACCESS_TOKEN url: `${process.env.NODE_ENV === "development" ? "http://localhost:5200/image" : "https://daemon.lbry.tech/image" }`
},
url: "http://daemon.lbry.tech/images.php"
}, (error, response, body) => { }, (error, response, body) => {
if (error) reject(error); if (error) resolve(error);
body = JSON.parse(body); body = JSON.parse(body);
resolve(body); resolve(body);
}); });

View file

@ -223,7 +223,7 @@ function generateMemeCreator(socket) {
body: { authorization: "hi" }, body: { authorization: "hi" },
json: true, json: true,
method: "GET", method: "GET",
url: `${process.env.NODE_ENV === "development" ? "http://localhost:5200" : "http://daemon.lbry.tech"}` url: `${process.env.NODE_ENV === "development" ? "http://localhost:5200" : "https://daemon.lbry.tech"}`
}).then(body => { }).then(body => {
console.log(body); console.log(body);
}).catch(welp => { }).catch(welp => {

View file

@ -28,7 +28,7 @@ module.exports = exports = pagePath => {
break; break;
case "/tour": case "/tour":
githubUrl = `${githubUrl}/views/pages/tour.js`; githubUrl = `${githubUrl}/views/partials/tour.js`;
break; break;
default: default: