New concept to directly upload files from server to Google Drive. It will give you a proxy and will automatically download files to server, after which you can easily upload it Google Drive or download it to your PC.
Somebody is requested to upload it to a high-speed server so that it's made open to all.
First clone the repo and install dependencies:
npm install
You have to make a google developers project and set the following environment variables:
Other environment variables:
https://thepiratebay.org
)Ensure that you request full google drive access permission and basic G+ info in your google project
To start server, run:
npm start
Heroku is no longer supported.
docker run -d -p 3000:3000 -e GOOGLE_CLIENT_ID='***' -e GOOGLE_CLIENT_SECRET='***' -e GOOGLE_REDIRECT_URL='***' mrigank11/embetacloud node server/server.js
Fill ***
with appropriate values.
If you want to debug, add -e DEBUG='eMCloud:*'
and remove the -d
eMbeta Cloud is debug compatible, to get debug info set environment variable DEBUG=eMCloud:*
and start server.
Adding new clouds is easy, just follow these steps:
/server/Storages/
(e.g. /server/Storages/DropBox
) and add .ts
file to it with same name as that of folder (say /server/Storages/DropBox/Dropbox.ts
)export class CloudName extends EventEmitter{
constructor(credentials){
super();
//store credentials, they can be username/password or OAuth Tokens etc.
}
static getURL(){
//return the url on which the user will be redirected for credentials, can be OAuth Consent Page or a page on server itself.
}
static callbackHandler(query,callback){
//handle the recieved credentials, 'query' contains the GET params. (like for OAuth, authentication code is 'query.code')
//after successfull authenticaltion, return creds to 'callback' to be stored as session variable
//if authentication fails, call the callback as: callback(0)
// when user requests a file upload, credentials from session will be used to initialize this class (the constructor will be called)
}
public uploadFile(readStream, totalSize, mime, filename){
//handle the upload procedure
//it should emit => progress : {name,bytesUploaded,size}
// fileUploaded : {size, name , error}
}
public uploadDir(localFolderPath){ //not necessary
//upload a local directory
//should emit => addSize : size size in bytes to be added to total upload size
//may emit => mkdir : name name of cloud directory created
}
}
For example, see /server/Storages/GDrive/GDrive.ts
/server/Storages/Storages.ts
(import it and add in storages
object)When user clicks login
, url is generated by calling getURL()
, it may be OAuth Consent Page or a custom one.
After redirection from OAuth Page(maybe other also), user is redirected to /oauthcallback/
with credentials as GET paramaters, callbackHandler(query)
is called with these params. After Successfull login, credentials passed to callback
are stored as session variables which are used to initialize this class i.e. constructor will be called with these creds.
getURL()
may redirect url to custom page. For Example: returning /login/mega
will open /server/Storages/mega/login.html