Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new project #12

Open
wants to merge 86 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
e7b9042
sendToMega function added
Dec 21, 2022
211c8ce
dependencies added
Dec 21, 2022
4eda9a2
route fixed
Dec 21, 2022
366b9dc
logs
Dec 21, 2022
fd448f3
mega-cmd testing
Dec 21, 2022
6ca74f0
testing
Dec 21, 2022
be429e4
logs checking
Dec 21, 2022
c8c1cd0
uname checking
Dec 21, 2022
d5497a1
uname checking
Dec 21, 2022
5eb63c9
installing megacmd to server
Dec 21, 2022
802ed1c
removed megacmd install script
Dec 21, 2022
abbcc7f
wget install
Dec 21, 2022
1b14676
wget install
Dec 21, 2022
325588c
mega setting
Dec 22, 2022
3774184
dep added
Dec 22, 2022
92dedac
path fixed
Dec 22, 2022
b7ed29a
name changed
Dec 22, 2022
33421d3
path fixed
Dec 22, 2022
c2e69ee
res set
Dec 22, 2022
77cc091
increasing myfiles.js file size for testing mega
Dec 22, 2022
93292c3
myfiles.js->myfile.js
Dec 22, 2022
13cbea5
Delete myfile.js
patra8821 Dec 24, 2022
d9d1a4f
myfile.js added
Dec 24, 2022
7ff58fe
testing log
Dec 24, 2022
ec05df8
myfile sise increase
Dec 24, 2022
bb2a0cd
myfile.js size increases
Dec 24, 2022
7ecd850
my file size 95mb
Dec 24, 2022
8bc37b8
myFile.js size 100mb
Dec 24, 2022
d4e4431
fresh
Dec 24, 2022
4761223
file upload client side
Dec 24, 2022
500cb3f
testing
Dec 24, 2022
e1010ae
testing
Dec 24, 2022
d27c4c3
testing
Dec 24, 2022
876052a
rote fix
Dec 24, 2022
2ccb7e3
route fixing
Dec 24, 2022
86b1cbb
file-upload calling
Dec 24, 2022
a51ed4e
testing logs checking of req
Dec 24, 2022
87e474e
route fixing
Dec 24, 2022
381ddc2
size
Dec 24, 2022
2ebcba2
route fixed
Dec 24, 2022
4c1c450
route
Dec 24, 2022
3bda30e
route
Dec 24, 2022
d9ad9fd
routes
Dec 24, 2022
afff8e7
routes
Dec 24, 2022
b40d624
testing
Dec 26, 2022
2221310
/uploads
Dec 26, 2022
cf39522
../uploads
Dec 26, 2022
cbf4e6f
__dirname + "/uploads/"
Dec 26, 2022
06e182e
testing
Dec 26, 2022
5d513cf
testing
Dec 26, 2022
a9f24a6
testing
Dec 26, 2022
78fe831
testing
Dec 26, 2022
47c876f
testing
Dec 26, 2022
bb28021
testing
Dec 26, 2022
3e34904
uploads->temp
Dec 26, 2022
4d7775c
uploads->/tmp
Dec 26, 2022
5f89139
fixing errors
Dec 26, 2022
735e230
testing
Dec 26, 2022
411d41f
testing
Dec 26, 2022
30be0f9
limit
Dec 26, 2022
4f44a7a
testing
Dec 26, 2022
1a3a2fe
limit set
Dec 26, 2022
4407794
bodyParser
Dec 26, 2022
82171e5
added urlencoded
Dec 26, 2022
97bd84b
nothing
Dec 26, 2022
bb36978
testing
Dec 26, 2022
006d965
limit removed
Dec 26, 2022
c6adfd8
urlencoded and json added
Dec 26, 2022
36b98cb
parameter limit increacing
Dec 26, 2022
bde4dfc
testing size
Dec 26, 2022
9c404b8
limit inc
Dec 26, 2022
d1efb5f
limits
Dec 26, 2022
d6273dd
multer update
Dec 26, 2022
9aed725
logs
Dec 26, 2022
7a66e67
extended: false
Dec 26, 2022
411927f
headers
Dec 26, 2022
fdf2f49
bytes
Dec 26, 2022
844e247
body-parser added
Dec 26, 2022
d3aaa5b
body-parser import
Dec 26, 2022
cbb93f9
added fileSize in multer
Dec 26, 2022
fa90acf
removed express.json
Dec 26, 2022
4de95a0
limit fixed
Dec 26, 2022
bba5cf3
root testing
Dec 26, 2022
d17a81e
route fixed
Dec 26, 2022
7e2f2e5
testing
Dec 26, 2022
45a6215
removed body-parser
Dec 26, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

testing
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

Expand Down
15 changes: 15 additions & 0 deletions function/fileUpload.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// const multer = require("multer");
// const { Storage } = require("megajs");

// const storage = multer.diskStorage({
// destination: "/tmp/",
// filename: function (req, file, cb) {
// console.log("called1");
// cb(null, file.originalname);
// },
// });

// module.exports = upload = multer({
// storage: storage,
// limits: { fileSize: "500mb" },
// });
80 changes: 80 additions & 0 deletions function/sendToMega.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
const fs = require("fs");
const { Storage } = require("megajs");

const sendToMega = async (req, res) => {
try {
console.log("called send-to-mega");
const file = req.file;
console.log(file);
const storage = await new Storage({
email: process.env.MEGA_EMAIL,
password: process.env.MEGA_PASSWORD,
}).ready;
console.log("logged in");
const data = fs.readFileSync(`/tmp/${file.filename}`);

const upFile = await storage.upload(file.originalname, data).complete;
fs.unlinkSync(file.path);
console.log("success");
res.status(200).json({ message: "success" });
} catch (error) {
console.log(error);
res.status(500).json(error);
}
};

module.exports = sendToMega;

// try {
// console.log("called");
// // const { data } = req.body;
// // const data = "dj";
// // fs.writeFile("hello.txt", data, () => {
// // console.log("file created");
// // });
// // const getWeget = spawn("apt install", ["wget"]);
// // getWeget.stdout.on("data", (data) => {
// // console.error(`weget: ${data}`);
// // });

// // const ls = spawn("wget", [
// // "https://mega.nz/linux/repo/Debian_11/amd64/megacmd-Debian_11_amd64.deb",
// // ]);
// // ls.stdin.write("sudo install ./megacmd-Debian_11_amd64.deb /");

// // ls.stdout.on("data", (data) => {
// // console.error(`weget: ${data}`);
// // });
// // const spawnedShell = spawn("mega-cmd");
// // spawnedShell.stdin.write(
// // `login ${process.env.MEGA_UPLOAD_LOGIN_URL} ${process.env.MEGA_UPLOAD_PASSWORD} \n`
// // );
// // spawnedShell.stdin.write("put ./hello.txt");

// // spawnedShell.stdout.on("data", (data) => {
// // console.log(`stdout: ${data}`);
// // });

// // spawnedShell.stderr.on("data", (data) => {
// // console.error(`stderr: ${data}`);
// // });

// // spawnedShell.on("close", (code) => {
// // console.log(`child process exited with code ${code}`);
// // });
// // spawnedShell.stdin.end()

// const storage = await new Storage({
// email: process.env.MEGA_EMAIL,
// password: process.env.MEGA_PASSWORD,
// }).ready;
// console.log("logged in");

// const data = fs.readFileSync("uploads/myfile.js");
// const upFile = await storage.upload("test.js", data).complete;
// console.log("success");
// res.status(200).json({ message: "success" });
// } catch (error) {
// console.log("error on sendToMega", error.message);
// res.status(500).json({ message: "Internal Server Error" });
// }
Binary file added megacmd-Debian_11_amd64.deb
Binary file not shown.
Loading