Upload image file to bucket success.
This commit is contained in:
14
index.js
14
index.js
@@ -59,13 +59,10 @@ setInterval(checkUpNotify, 1000 * 60 * 60 * 24);
|
||||
|
||||
//Google storage req
|
||||
const PROJECT_ID = "marketalarm";
|
||||
const KEY_FILENAME = "marketalarm-262e746e533c.json"; //relative path
|
||||
const KEY_FILENAME = ""; //relative path
|
||||
const BUCKET_NAME = "marketalarm-photos";
|
||||
//Tried implicitly creating with env credentials and direktcly as here
|
||||
const storage = new Storage({
|
||||
projectId: PROJECT_ID,
|
||||
keyFilename: KEY_FILENAME
|
||||
});
|
||||
const storage = new Storage();
|
||||
|
||||
const bucket = storage.bucket(BUCKET_NAME);
|
||||
|
||||
@@ -77,8 +74,7 @@ app.get("/generateSignedURL", (req, res) => {
|
||||
//Tried to define Google ID and private key while debugging
|
||||
version: "v2", //tried v4 also
|
||||
action: "write",
|
||||
"Content-Type": "image/*",
|
||||
//contentType: "image/*", //tried without and with specific image/png ex.
|
||||
contentType: "image/*", //tried without and with specific image/png ex.
|
||||
expires: Date.now() + 86400000
|
||||
};
|
||||
const filename = req.query.filename;
|
||||
@@ -90,10 +86,6 @@ app.get("/generateSignedURL", (req, res) => {
|
||||
|
||||
console.log(`The signed url is ${url}.`);
|
||||
|
||||
res.header("Access-Control-Allow-Origin", "http://localhost:5000");
|
||||
res.header("Access-Control-Allow-Methods", "PUT,OPTIONS");
|
||||
res.header("Access-Control-Allow-Headers", "Content-Type, Origin");
|
||||
res.header("Access-Control-Max-Age", "86400000");
|
||||
res.status(200).send(url);
|
||||
}
|
||||
generateSignedUrl().catch(console.error);
|
||||
|
||||
Reference in New Issue
Block a user