https://github.com/leafo/url2gs
Command line tool to copy the contents of a HTTP URL to Google Cloud Storage
https://github.com/leafo/url2gs
Last synced: 11 months ago
JSON representation
Command line tool to copy the contents of a HTTP URL to Google Cloud Storage
- Host: GitHub
- URL: https://github.com/leafo/url2gs
- Owner: leafo
- Created: 2014-06-08T19:43:35.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2014-06-10T03:57:21.000Z (about 12 years ago)
- Last Synced: 2025-02-23T08:13:58.011Z (over 1 year ago)
- Language: Go
- Size: 148 KB
- Stars: 2
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# url2gs
Uploads a file to Google Cloud storage from a HTTP URL.
If you just need a quick way to do it you can use the command line:
```bash
curl -f http://leafo.net/hi.png | gsutil -h "Content-Type:image/png" cp -a public-read - gs://leafo/hi.png
```
But if you want to handle HTTP status codes and limit the size of file that can
be uploaded then this tool is for you.
## Usage
Install
```bash
go get github.com/leafo/url2gs
```
```bash
$ url2gs -help
Usage: url2gs [OPTIONS] http://URL gs://BUCKET/KEY
Options:
-acl="public-read": ACL of uploaded file
-config="url2gs.json": Path to json config file
-content_disposition="": Content disposition of uploaded file
-content_type="": Content type of uploaded file (defaults to content type from HTTP request)
-max_bytes=0: Max bytes to copy (0 is no limit)
```
Create a config file:
`url2gs.json`:
```json
{
"PrivateKeyPath": "path/to/service/key.pem",
"ClientEmail": "111111111111@developer.gserviceaccount.com"
}
```
Run:
```bash
$GOPATH/bin/url2gs -max_bytes=5000000 http://leafo.net/hi.png gs://leafo/hi.png
```
If the command succeeds then an exit code of 0 is returend, on failure 1 is
returned. Only requests that return a 200 status code are copied. The mime type
of the file is extracted from the `Content-Type` of the URL.