-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 179b432
Showing
12 changed files
with
795 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Compiled Object files, Static and Dynamic libs (Shared Objects) | ||
*.o | ||
*.a | ||
*.so | ||
|
||
# Folders | ||
_obj | ||
_test | ||
|
||
# Architecture specific extensions/prefixes | ||
*.[568vq] | ||
[568vq].out | ||
|
||
*.cgo1.go | ||
*.cgo2.c | ||
_cgo_defun.c | ||
_cgo_gotypes.go | ||
_cgo_export.* | ||
|
||
_testmain.go | ||
|
||
*.exe | ||
*.test | ||
*.prof | ||
nohup.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2015-present Cloud | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
# Cloud Upload | ||
|
||
Upload files to multiple cloud storage in parallel. | ||
|
||
### Download | ||
|
||
#### Binary | ||
|
||
Download from (releases)[https://github.com/txthinking/cloudupload/releases] page. | ||
|
||
#### Source | ||
|
||
``` | ||
$ go get github.com/txthinking/cloudupload/cli/cloudupload | ||
``` | ||
|
||
### Run | ||
|
||
``` | ||
NAME: | ||
Cloud Upload - Upload files to multiple cloud storage in parallel | ||
USAGE: | ||
main [global options] command [command options] [arguments...] | ||
VERSION: | ||
20181008 | ||
AUTHOR: | ||
Cloud <[email protected]> | ||
COMMANDS: | ||
help, h Shows a list of commands or help for one command | ||
GLOBAL OPTIONS: | ||
--debug, -d Enable debug, more logs | ||
--debugListen value, -l value Listen address for debug (default: "127.0.0.1:6060") | ||
--listen value Listen address | ||
--domain value If domain is specified, 80 and 443 ports will be used. Listen address is no longer needed | ||
--maxBodySize value Max size of http body, M (default: 0) | ||
--timeout value Read timeout, write timeout x2, idle timeout x20, s (default: 0) | ||
--origin value Allow origins for CORS, can repeat more times. like https://google.com, suggest add https://google.com/ too | ||
--enableLocal Enable local store | ||
--localStorage value Local directory path | ||
--enableGoogle Enable google store, first needs $ gcloud auth application-default login | ||
--googleBucket value Google bucket name | ||
--enableAliyun Enable aliyun OSS | ||
--aliyunAccessKeyID value Aliyun access key id | ||
--aliyunAccessKeySecret value Aliyun access key secret | ||
--aliyunEndpoint value Aliyun endpoint, like: https://oss-cn-shanghai.aliyuncs.com | ||
--aliyunBucket value Aliyun bucket name | ||
--enableTencent Enable Tencent | ||
--tencentSecretId value Tencent secret id | ||
--tencentSecretKey value Tencent secret key | ||
--tencentHost value domain | ||
--help, -h show help | ||
--version, -v print the version | ||
``` | ||
|
||
### Upload | ||
|
||
#### Request | ||
|
||
* Method: `POST` | ||
* Header: | ||
* `Accept`, one of: | ||
* `application/json` | ||
* `text/plain` | ||
* `Content-Type`, one of: | ||
* `application/octet-stream` | ||
* `application/base64` | ||
* `multipart/form-data...`, field name: `file` | ||
* `X-File-Name`: | ||
* Full file name with suffix, Only required when `Content-Type` is `application/octet-stream` or `application/base64`. | ||
* Body, one of: | ||
* Binary file content when `Content-Type` is `application/octet-stream`. | ||
* Base64 encoded file content when `Content-Type` is `application/octet-stream`. | ||
* Multipart form data when `Content-Type` is `multipart/form-data...`. | ||
|
||
#### Response | ||
|
||
* Status Code: 200 | ||
* Content-Type, one of: | ||
* `application/json` | ||
* `text/plain; charset=utf-8` | ||
* Body: | ||
* File path | ||
* `{ "file": "file path" }` | ||
* Status Code: !200 | ||
* Content-Type: | ||
* `text/plain; charset=utf-8` | ||
* Body: | ||
* Error message | ||
|
||
### Example | ||
|
||
``` | ||
$ curl -H 'Content-Type: application/octet-stream' -H 'X-File-Name: Angry.png' --data-binary @Angry.png https://yourdomain.com | ||
vbpovzsdzbxu/Angry.png | ||
$ curl -F '[email protected]' https://yourdomain.com | ||
vbpovzsdzbxu/Angry.png | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package cloudupload | ||
|
||
import ( | ||
"io" | ||
|
||
"github.com/aliyun/aliyun-oss-go-sdk/oss" | ||
) | ||
|
||
type Aliyun struct { | ||
AccessKeyID string | ||
AccessKeySecret string | ||
Endpoint string | ||
Bucket string | ||
} | ||
|
||
func (a *Aliyun) Save(name string, r io.Reader) error { | ||
client, err := oss.New(a.Endpoint, a.AccessKeyID, a.AccessKeySecret) | ||
if err != nil { | ||
return err | ||
} | ||
bucket, err := client.Bucket(a.Bucket) | ||
if err != nil { | ||
return err | ||
} | ||
if err := bucket.PutObject(name, r); err != nil { | ||
return err | ||
} | ||
return nil | ||
} |
Oops, something went wrong.