Skip to content

Commit

Permalink
Uploads folder moved to home directory
Browse files Browse the repository at this point in the history
  • Loading branch information
Rishi-Bidani committed Jun 2, 2021
1 parent 379897a commit 7fca2e0
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 11 deletions.
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# local-cloud

## Version 2.3 coming soon with several new features!!

This project is still under development (**Not** in early stages anymore), It has several features already implemented :bangbang:

This program can turn your desktop into a local cloud server. This is a website which will run locally over your wifi(without port forwarding) and will be accessible to all your devices.
Expand All @@ -10,6 +8,19 @@ You can now access and transfer files from your different devices with ease.
The new version (version 2) has been implemented using vuejs.
Version 1 was a pilot project and is not recommended for use(it is not supported by me any longer).

## Version 2.3 coming soon with several new features !!

### What's new

- Delete Files
- Download from releases, the app is finally PACKAGED as an executable!! You don't need to download nodejs or anything else anymore
- delete folder (in context menu- right click)
- download entire folder (in context menu- right click)
- Upload folder has shifted to home directory
- For windows => Users > username > HomeCloud
- You don't need to look for your ipv4 address anymore, it displays it for you
<br />

## Table Of Contents

- [Images](#images):file_folder:
Expand Down Expand Up @@ -66,7 +77,7 @@ a better bundled package
yarn serve
```

3. THe website can be found on ipv4:8080, check version 1 procedure to see how you can find your ipv4 address.
3. The website can be found on ipv4:8080, check version 1 procedure to see how you can find your ipv4 address.

<b>For version 1</b>
<br />
Expand Down Expand Up @@ -122,6 +133,7 @@ docker-compose up -d
- <a href="https://www.npmjs.com/package/vue-sidebar-menu">vue-sidebar-menu</a>
- <a href="https://www.npmjs.com/package/vue-js-modal">vue-js-modal</a>
- <a href="https://github.com/Mostafa-Samir/zip-local">zip-local</a>
- <a href="https://www.npmjs.com/package/local-ipv4-address">local-ipv4-address</a>

<a name="plans"></a>

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"dropzone": "^5.9.2",
"express": "^4.17.1",
"fs": "^0.0.1-security",
"local-ipv4-address": "^0.0.2",
"multer": "^1.4.2",
"zip-local": "^0.3.4"
},
Expand Down
21 changes: 15 additions & 6 deletions server/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,42 @@ const http = require("http").Server(app);
const path = require("path");
const fs = require("fs");
const cors = require("cors");
const uploadsFolder = path.join(__dirname, "../uploads");
const localIpV4Address = require("local-ipv4-address");
const os = require("os");
const dirname = process.cwd();
const uploadsFolder = path.join(os.homedir(), "HomeCloud");
// const uploadsFolder = path.join(__dirname, "../uploads");

// MiddleWare
app.use(express.json());
app.use(cors());

// Create an Uploads FOlder if it doesn't exist
// Create an Uploads Folder if it doesn't exist
if (!fs.existsSync(uploadsFolder)) {
fs.mkdirSync(uploadsFolder);
// fs.mkdirSync(uploadsFolder);
fs.mkdirSync(path.join(os.homedir(), "HomeCloud"));
} else {
}

// Any posts requests will be handled by the following file
const posts = require("./routes/posts");
app.use("/posts", posts);

app.use(express.static(path.join(__dirname, "public")));
// app.use(express.static(path.join(__dirname, "public")));
app.use(express.static(path.join(dirname, "server", "public")));

app.get("/.*/", (req, res) => {
// res.send("Hello World");
res.sendFile(path.join(__dirname, "public", "index.html"));
// res.sendFile(path.join(__dirname, "public", "index.html"));
res.sendFile(path.join(dirname, "server", "public", "index.html"));
});

// Use default port during production, else 5000
// Running on 0.0.0.0 instead of localhost so that its accessible to other devices
// Example address 196.168.1.7:5000
const port = process.env.PORT || 5000;
http.listen(port, "0.0.0.0", () => {
console.log(`listening on port ${port}`);
localIpV4Address().then(function (ipAddress) {
console.log(`Website live on: ${ipAddress}:${port}`);
});
});
8 changes: 6 additions & 2 deletions server/routes/posts.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ const express = require("express");
const fs = require("fs");
const router = express.Router();
const path = require("path");
const uploadsFolder = path.join(__dirname, "../../uploads");
// const uploadsFolder = path.join(__dirname, "../../uploads");
const multer = require("multer");
const zipper = require("zip-local");

const os = require("os");
const uploadsFolder = path.join(os.homedir(), "HomeCloud");

// Setup storage for multer middleware
var storage = multer.diskStorage({
destination: path.join(__dirname, "../../uploads"),
// destination: path.join(__dirname, "../../uploads"),
destination: path.join(uploadsFolder),
filename: function (req, file, cb) {
cb(null, file.originalname);
},
Expand Down
12 changes: 12 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,13 @@ latest-version@^5.0.0:
dependencies:
package-json "^6.3.0"

local-ipv4-address@^0.0.2:
version "0.0.2"
resolved "https://registry.yarnpkg.com/local-ipv4-address/-/local-ipv4-address-0.0.2.tgz#0d6507101083b37205bf7297b92b34aa660291b7"
integrity sha1-DWUHEBCDs3IFv3KXuSs0qmYCkbc=
dependencies:
q "1.5.0"

lowercase-keys@^1.0.0, lowercase-keys@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-1.0.1.tgz#6f9e30b47084d971a7c820ff15a6c5167b74c26f"
Expand Down Expand Up @@ -961,6 +968,11 @@ pupa@^2.0.1:
dependencies:
escape-goat "^2.0.0"

[email protected]:
version "1.5.0"
resolved "https://registry.yarnpkg.com/q/-/q-1.5.0.tgz#dd01bac9d06d30e6f219aecb8253ee9ebdc308f1"
integrity sha1-3QG6ydBtMObyGa7LglPunr3DCPE=

q@^1.4.1:
version "1.5.1"
resolved "https://registry.yarnpkg.com/q/-/q-1.5.1.tgz#7e32f75b41381291d04611f1bf14109ac00651d7"
Expand Down

0 comments on commit 7fca2e0

Please sign in to comment.