r2-explorer 0.2.4 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -17
- package/bin/r2-explorer.js +26 -21
- package/dist/umd/index.js +75 -43
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -2,27 +2,68 @@
|
|
|
2
2
|
|
|
3
3
|
A Google Drive Interface for your Cloudflare R2 Buckets!
|
|
4
4
|
|
|
5
|
+
This project is deployed/self-hosted in your own Cloudflare Account as a Worker, and no credential/token is required to start using it.
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Cloudflare Access is used as a very basic authentication mechanism, in order to save r2 credentials in the a KV.
|
|
9
|
-
|
|
10
|
-
You can test this right now in your browser in https://r2.massadas.com/
|
|
11
|
-
|
|
7
|
+
You can see an live example, in `read-only` mode, in your browser at https://r2-explorer.massadas.com/
|
|
12
8
|
|
|
13
9
|
## Features
|
|
14
|
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
10
|
+
|
|
11
|
+
- Very quick bucket/folder navigation
|
|
12
|
+
- pdf, image, txt, markdown, etc in-browser preview
|
|
13
|
+
- Drag-and-Drop upload
|
|
18
14
|
- Create folders
|
|
19
15
|
- Rename files
|
|
20
16
|
- Download files
|
|
21
17
|
- Delete files
|
|
22
|
-
- Right click
|
|
18
|
+
- Right click in file for extra options
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
## FAQ
|
|
22
|
+
|
|
23
|
+
Q. Is there any Authentication for r2-explorer?
|
|
24
|
+
|
|
25
|
+
A. No. If you want authenticated access, you must setup [Cloudflare Access](https://www.cloudflare.com/products/zero-trust/access/) in your account.
|
|
26
|
+
Access is free up to 50 users.
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
## Getting Started
|
|
30
|
+
|
|
31
|
+
Run this command to get an example project setup
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npx r2-explorer my-r2-explorer
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Change into the newly created directory and install the packages
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
cd my-r2-explorer
|
|
41
|
+
npm install
|
|
42
|
+
```
|
|
23
43
|
|
|
44
|
+
Update the `wrangler.toml` with your R2 Buckets (tip: you can setup as many Buckets as your want)
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
- wrangler.toml -
|
|
48
|
+
...
|
|
49
|
+
[[r2_buckets]]
|
|
50
|
+
binding = 'my-bucket-name'
|
|
51
|
+
bucket_name = 'my-bucket-name'
|
|
52
|
+
preview_bucket_name = 'my-bucket-name'
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
If you want to be able to upload/modify your buckets, you must update the `readonly` flag in `src/index.ts` file.
|
|
56
|
+
|
|
57
|
+
After that just run publish and the project will be up and running for you and everyone you invite to use the Buckets
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
wrangler publish
|
|
61
|
+
```
|
|
24
62
|
|
|
25
63
|
## TODO
|
|
64
|
+
|
|
65
|
+
- Integration with cloudflare access
|
|
66
|
+
- allow bucket names with spaces
|
|
26
67
|
- Search files
|
|
27
68
|
- CSV Previewer
|
|
28
69
|
- Upload folders
|
|
@@ -33,14 +74,10 @@ You can test this right now in your browser in https://r2.massadas.com/
|
|
|
33
74
|
- Upload folders with files
|
|
34
75
|
- Automatically load more files, when the bottom is reached (current limit is 1000 files)
|
|
35
76
|
- Download files bigger than 2gb with presigned url's
|
|
36
|
-
- Allow user to pick to save credentials in cloud or in browser local storage
|
|
37
|
-
|
|
38
77
|
|
|
39
78
|
## Known issues
|
|
40
|
-
- Because r2 don't have signed url's the file downloads is made to local storage then it is downloaded as an url.
|
|
41
|
-
This as a limitation of around 2gb of max file
|
|
42
|
-
- Rename files with special characters is not possible with current [sdk issue here](https://github.com/aws/aws-sdk-js/issues/1949)
|
|
43
79
|
|
|
80
|
+
- Rename files with special characters is not possible with current [sdk issue here](https://github.com/aws/aws-sdk-js/issues/1949)
|
|
44
81
|
|
|
45
82
|
## Images
|
|
46
83
|
|
|
@@ -59,18 +96,20 @@ New Folder
|
|
|
59
96
|
Uploading Files
|
|
60
97
|

|
|
61
98
|
|
|
62
|
-
|
|
63
99
|
### Compiles and hot-reloads for development
|
|
100
|
+
|
|
64
101
|
```
|
|
65
102
|
npm run serve
|
|
66
103
|
```
|
|
67
104
|
|
|
68
105
|
### Compiles and minifies for production
|
|
106
|
+
|
|
69
107
|
```
|
|
70
108
|
npm run build
|
|
71
109
|
```
|
|
72
110
|
|
|
73
111
|
### Lints and fixes files
|
|
112
|
+
|
|
74
113
|
```
|
|
75
114
|
npm run lint
|
|
76
115
|
```
|
package/bin/r2-explorer.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
#! /usr/bin/env node
|
|
2
|
-
var fs = require('fs')
|
|
2
|
+
var fs = require('fs')
|
|
3
3
|
|
|
4
|
-
const args = process.argv.slice(2)
|
|
5
|
-
const projectName = args[0] || 'r2-explorer'
|
|
4
|
+
const args = process.argv.slice(2)
|
|
5
|
+
const projectName = args[0] || 'r2-explorer'
|
|
6
6
|
|
|
7
7
|
const dir = `./${projectName}`
|
|
8
8
|
if (!fs.existsSync(dir)) {
|
|
9
|
-
fs.mkdirSync(dir)
|
|
9
|
+
fs.mkdirSync(dir)
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
fs.writeFileSync(
|
|
12
|
+
fs.writeFileSync(
|
|
13
|
+
`${dir}/wrangler.toml`,
|
|
13
14
|
`name = "${projectName}"
|
|
14
15
|
compatibility_date = "2022-08-09"
|
|
15
16
|
main = "src/index.js"
|
|
@@ -18,8 +19,10 @@ main = "src/index.js"
|
|
|
18
19
|
binding = 'my-bucket-name'
|
|
19
20
|
bucket_name = 'my-bucket-name'
|
|
20
21
|
preview_bucket_name = 'my-bucket-name'
|
|
21
|
-
`
|
|
22
|
-
|
|
22
|
+
`
|
|
23
|
+
)
|
|
24
|
+
fs.writeFileSync(
|
|
25
|
+
`${dir}/package.json`,
|
|
23
26
|
`{
|
|
24
27
|
"name": "${projectName}",
|
|
25
28
|
"version": "0.0.1",
|
|
@@ -31,35 +34,37 @@ fs.writeFileSync(`${dir}/package.json`,
|
|
|
31
34
|
"publish": "wrangler publish"
|
|
32
35
|
},
|
|
33
36
|
"dependencies": {
|
|
34
|
-
"r2-explorer": "^0.2.
|
|
37
|
+
"r2-explorer": "^0.2.6"
|
|
35
38
|
}
|
|
36
39
|
}
|
|
37
40
|
|
|
38
|
-
`
|
|
41
|
+
`
|
|
42
|
+
)
|
|
39
43
|
|
|
40
44
|
const srcDir = `${dir}/src`
|
|
41
45
|
if (!fs.existsSync(srcDir)) {
|
|
42
|
-
fs.mkdirSync(srcDir)
|
|
46
|
+
fs.mkdirSync(srcDir)
|
|
43
47
|
}
|
|
44
48
|
|
|
45
|
-
fs.writeFileSync(
|
|
49
|
+
fs.writeFileSync(
|
|
50
|
+
`${srcDir}/index.js`,
|
|
46
51
|
`import { R2Explorer } from 'r2-explorer';
|
|
47
52
|
|
|
48
|
-
const explorer = R2Explorer()
|
|
53
|
+
const explorer = R2Explorer({ readonly: true })
|
|
49
54
|
|
|
50
55
|
export default {
|
|
51
56
|
async fetch(request, env, context) {
|
|
52
57
|
return explorer.handle(request, env, context)
|
|
53
58
|
}
|
|
54
59
|
};
|
|
55
|
-
`
|
|
60
|
+
`
|
|
61
|
+
)
|
|
56
62
|
|
|
63
|
+
console.log(`Project ${projectName} successfully created!`)
|
|
64
|
+
console.log('----------------------------')
|
|
65
|
+
console.log('Next steps:')
|
|
66
|
+
console.log(` 1. Run 'cd ${projectName} && npm install'`)
|
|
67
|
+
console.log(" 2. Update the 'wrangler.toml' file with your R2 Buckets")
|
|
68
|
+
console.log(" 3. Run 'wrangler publish' to deploy your own R2-Explorer!")
|
|
57
69
|
|
|
58
|
-
|
|
59
|
-
console.log('----------------------------');
|
|
60
|
-
console.log('Next steps:');
|
|
61
|
-
console.log(` 1. Run 'cd ${projectName} && npm install'`);
|
|
62
|
-
console.log(' 2. Update the \'wrangler.toml\' file with your R2 Buckets');
|
|
63
|
-
console.log(' 3. Run \'wrangler publish\' to deploy your own R2-Explorer!');
|
|
64
|
-
|
|
65
|
-
process.exit(0); //no errors occurred
|
|
70
|
+
process.exit(0) //no errors occurred
|