Comparing version 0.3.0 to 0.3.1
33
cli.js
@@ -35,5 +35,6 @@ #!/usr/bin/env node | ||
'put': cmdPut, | ||
'get': cmdGet, | ||
}; | ||
var isS3UrlRe = /^[sS]3:\/\//; | ||
var s3UrlRe = /^[sS]3:\/\/(.*?)\/(.*)/; | ||
@@ -189,3 +190,3 @@ var client; | ||
Bucket: parts.bucket, | ||
Key: parts.Key, | ||
Key: parts.key, | ||
ACL: getAcl(), | ||
@@ -203,2 +204,20 @@ ContentType: getContentType(source), | ||
function cmdGet() { | ||
var source = args._[0]; | ||
var dest = args._[1]; | ||
var parts = parseS3Url(source); | ||
if (!dest) { | ||
dest = path.basename(source); | ||
} | ||
var params = { | ||
localFile: dest, | ||
s3Params: { | ||
Bucket: parts.bucket, | ||
Key: parts.key, | ||
}, | ||
}; | ||
var downloader = client.downloadFile(params); | ||
setUpProgress(downloader); | ||
} | ||
function cmdHelp() { | ||
@@ -214,4 +233,4 @@ console.log("Usage: s3 (command) (command arguments)"); | ||
} | ||
var parts = url.parse(s3Url); | ||
if (parts.protocol !== 's3:') { | ||
var match = s3Url.match(s3UrlRe); | ||
if (!match) { | ||
console.error("Not a valid S3 URL:", s3Url); | ||
@@ -221,4 +240,4 @@ process.exit(1); | ||
return { | ||
bucket: parts.hostname, | ||
key: parts.path.replace(/^\//, ""), | ||
bucket: match[1], | ||
key: match[2], | ||
}; | ||
@@ -228,3 +247,3 @@ } | ||
function isS3Url(str) { | ||
return isS3UrlRe.test(str); | ||
return s3UrlRe.test(str); | ||
} | ||
@@ -231,0 +250,0 @@ |
{ | ||
"name": "s3-cli", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "command line utility to go along with s3 module", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -9,3 +9,3 @@ # s3 cli | ||
* Supports a subset of s3cmd's commands and parameters | ||
- including `put`, `del`, `ls`, `sync` | ||
- including `put`, `get`, `del`, `ls`, `sync` | ||
@@ -18,5 +18,5 @@ ## Install | ||
### ls | ||
### put | ||
Lists S3 objects. | ||
Uploads a file to S3. | ||
@@ -26,18 +26,29 @@ Example: | ||
``` | ||
s3-cli ls [--recursive] s3://mybucketname/this/is/the/key/ | ||
s3-cli put /path/to/file s3://bucket/key/on/s3 | ||
``` | ||
### sync | ||
Options: | ||
#### Sync a local directory to S3 | ||
* `--acl-public` or `-P` - Store objects with ACL allowing read for anyone. | ||
* `--default-mime-type` - Default MIME-type for stored objects. Application | ||
default is `binary/octet-stream`. | ||
* `--no-guess-mime-type` - Don't guess MIME-type and use the default type | ||
instead. | ||
* `--add-header=NAME:VALUE` - Add a given HTTP header to the upload request. Can be | ||
used multiple times. For instance set 'Expires' or 'Cache-Control' headers | ||
(or both) using this options if you like. | ||
### get | ||
Downloads a file from S3. | ||
Example: | ||
``` | ||
s3-cli sync [--delete-removed] /path/to/folder/ s3://bucket/key/on/s3/ | ||
s3-cli get s3://bucket/key/on/s3 /path/to/file | ||
``` | ||
Supports the same options as `put`. | ||
### del | ||
#### Sync a directory on S3 to disk | ||
Deletes an object or a directory on S3. | ||
@@ -47,8 +58,8 @@ Example: | ||
``` | ||
s3-cli sync [--delete-removed] s3://bucket/key/on/s3/ /path/to/folder/ | ||
s3-cli del [--recursive] s3://bucket/key/on/s3/ | ||
``` | ||
### del | ||
### ls | ||
Deletes an object or a directory on S3. | ||
Lists S3 objects. | ||
@@ -58,8 +69,8 @@ Example: | ||
``` | ||
s3-cli del [--recursive] s3://bucket/key/on/s3/ | ||
s3-cli ls [--recursive] s3://mybucketname/this/is/the/key/ | ||
``` | ||
### put | ||
### sync | ||
Uploads a file to S3. | ||
#### Sync a local directory to S3 | ||
@@ -69,14 +80,13 @@ Example: | ||
``` | ||
s3-cli put /path/to/file s3://bucket/key/on/s3 | ||
s3-cli sync [--delete-removed] /path/to/folder/ s3://bucket/key/on/s3/ | ||
``` | ||
Options: | ||
Supports the same options as `put`. | ||
* `--acl-public` or `-P` - Store objects with ACL allowing read for anyone. | ||
* `--default-mime-type` - Default MIME-type for stored objects. Application | ||
default is `binary/octet-stream`. | ||
* `--no-guess-mime-type` - Don't guess MIME-type and use the default type | ||
instead. | ||
* `--add-header=NAME:VALUE` - Add a given HTTP header to the upload request. Can be | ||
used multiple times. For instance set 'Expires' or 'Cache-Control' headers | ||
(or both) using this options if you like. | ||
#### Sync a directory on S3 to disk | ||
Example: | ||
``` | ||
s3-cli sync [--delete-removed] s3://bucket/key/on/s3/ /path/to/folder/ | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9931
294
87