Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
cloudflare-gdrive
Advanced tools
Leverage Google Drive as File Server (with direct download, fileupload, and urlupload feature) using Cloudflare Workers
Leverage Google Drive as File Server (with direct download, fileupload, and urlupload feature) using Cloudflare Workers.
Get your refresh token
(using rclone).
Follow Workers Get Started Guide, or use my template.
Install cloudflare-gdrive
package
yarn add cloudflare-gdrive
createHandler
import from cloudflare-gdrive
to create the handler
.Options:
base
: Only accept request prefixed with this string, default to '' (accept all requests).oauth
: Putclient_id
,client_secret
, andrefresh_token
you got from step 1 here.requireAuth
: Record of HTTP Methods (GET
andPOST
) mapped with Bearer Token to authorize the client (POST
is required,GET
optional).rootFolderId
: ID of the Google Drive folder you wish to be atbase
path, default to 'root' (your My Drive folder).
import { createHandler } from 'cloudflare-gdrive'
const fetchHandler = () => {
return createHandler({
base: '/api',
oauth: {
clientId: YOUR_CLIENT_ID,
clientSecret: YOUR_CLIENT_SECRET,
refreshToken: YOUR_REFRESH_TOKEN,
},
requireAuth: {
GET: 'tokenhere',
POST: 'veryhardbearertoken',
},
rootFolderId:
'0B8VJ-gRi4t_9fnZzWGZHMzNBSG9lR1JlRGxwMGVZWUlONzdBeVB3dnRPTDgyQUJwT3RpMVU',
})
}
export default {
fetch: fetchHandler,
}
GET
GET-ting is pretty straight forward. You can fetch as you would like while using ftp
, the path will be mapped to the correct file.
GET http://example.com/path/to/file/
GET http://example.com/?list
response:
[
{
"mimeType": "application/vnd.google-apps.folder",
"path": "/test/",
"url": "http://example.com/test/",
"id": "1JFE64puRxwB3MdasFrumhTFYcFxJiN4Z"
},
{
"mimeType": "text/plain",
"path": "/text.txt",
"url": "http://example.com/text.txt",
"id": "13FmU4rGY2j5NLmzW0cmxetlHvYpF0eET",
"size": "18848"
}
]
Recurse folder once.
GET http://example.com/?list&recurse=1
response:
[
{
"mimeType": "application/vnd.google-apps.folder",
"path": "/test/",
"url": "http://example.com/test/",
"id": "1JFE64puRxwB3MdasFrumhTFYcFxJiN4Z"
},
{
"mimeType": "text/plain",
"path": "/test/no.txt",
"url": "http://example.com/test/no.txt",
"id": "1--ZX0dbRcpw1JItDMIKNIBl9Ej1g12sG",
"size": "28592"
},
{
"mimeType": "text/plain",
"path": "/text.txt",
"url": "http://example.com/text.txt",
"id": "13FmU4rGY2j5NLmzW0cmxetlHvYpF0eET",
"size": "18848"
}
]
List, but without folders.
GET http://example.com/?list&nofolder
response:
[
{
"mimeType": "text/plain",
"path": "/text.txt",
"url": "http://example.com/text.txt",
"id": "13FmU4rGY2j5NLmzW0cmxetlHvYpF0eET",
"size": "18848"
}
]
POST
Post is used to upload files using multipart/form-data
, either from URL or from your machine. Examples below will be using cURL.
Required form:
mode
: upload mode, set withurlupload
.url
: url of the content you wish to upload.Optional form:
path
: folder path to save the content (default to/
)filename
: saved filename (default to url's last segment)
Upload file from https://images.pexels.com/photos/104827/cat-pet-animal-domestic-104827.jpeg
to folder /private/cat
with name cat.jpeg
.
curl --request POST http://example.com \
-F "mode=urlupload" \
-F "url=https://images.pexels.com/photos/104827/cat-pet-animal-domestic-104827.jpeg" \
-F "path=/private/cat" \
-F "filename=cat.jpeg"
Required form:
mode
: upload mode, set withfileupload
.file
: the file.Optional form:
path
: folder path to save the content (default to/
)filename
: saved filename (default to file's filename)
Upload mycat.jpeg
to folder /private/cat
with name cat.jpeg
.
curl --request POST http://example.com \
-F "mode=fileupload" \
-F "file=@mycat.jpeg" \
-F "path=/private/cat" \
-F "filename=cat.jpeg"
path
folder if not exists (including parent folders).refresh_token
Install rclone.
Create your own Google Drive client_id.
Create a Google Drive remote in rclone and fill in client_id
and client_secret
with the one you made before.
Copy the refresh_token
in this step (it's the last step).
...
[remote]
client_id =
client_secret =
scope = drive
root_folder_id =
service_account_file =
token = {"access_token":"XXX","token_type":"Bearer","refresh_token":"XXX","expiry":"2014-03-16T13:57:58.955387075Z"}
---
y) Yes this is OK
e) Edit this remote
d) Delete this remote
...
FAQs
Leverage Google Drive as File Server (with direct download, fileupload, and urlupload feature) using Cloudflare Workers
The npm package cloudflare-gdrive receives a total of 0 weekly downloads. As such, cloudflare-gdrive popularity was classified as not popular.
We found that cloudflare-gdrive demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.