Skip to content

Commit

Permalink
chore: update the arg endpoint to the region
Browse files Browse the repository at this point in the history
  • Loading branch information
saltbo committed May 17, 2020
1 parent 473b53d commit 0d0e3fd
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 20 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ jobs:
UPLOADER_OSS_SK: ${{ secrets.UPLOADER_OSS_SK }}
UPLOADER_QINIU_AK: ${{ secrets.UPLOADER_QINIU_AK }}
UPLOADER_QINIU_SK: ${{ secrets.UPLOADER_QINIU_SK }}
UPLOADER_STORAGE_AK: ${{ secrets.UPLOADER_STORAGE_AK }}
UPLOADER_STORAGE_SK: ${{ secrets.UPLOADER_STORAGE_SK }}
UPLOADER_S3_AK: ${{ secrets.UPLOADER_S3_AK }}
UPLOADER_S3_SK: ${{ secrets.UPLOADER_S3_SK }}
UPLOADER_GOOGLE_SK: ${{ secrets.UPLOADER_GOOGLE_SK }}
- name: Upload Coverage report to CodeCov
uses: codecov/codecov-action@v1.0.0
with:
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ curl -sSf http://uptoc.saltbo.cn/install.sh | sh

### Basic
```bash
uptoc --endpoint oss-cn-beijing.aliyuncs.com --access_key LTAI4FxxxxxxxBXmS3 --access_secret Vt1FZgxxxxxxxxxxxxKp380AI --bucket demo-bucket /opt/blog/public
uptoc --driver oss --region cn-beijing --access_key LTAI4FxxxxxxxBXmS3 --access_secret Vt1FZgxxxxxxxxxxxxKp380AI --bucket demo-bucket /opt/blog/public
```

And the access-key and access-secret support settings by the system environment
```bash
export UPTOC_UPLOADER_AK=LTAI4FxxxxxxxBXmS3
export UPTOC_UPLOADER_SK=Vt1FZgxxxxxxxxxxxxKp380AI

uptoc --endpoint oss-cn-beijing.aliyuncs.com --bucket blog-bucket /opt/blog/public
uptoc --driver oss --region cn-beijing --bucket blog-bucket /opt/blog/public
```

### Github Actions
Expand All @@ -50,7 +50,7 @@ steps:
uses: saltbo/uptoc@master
with:
driver: oss
endpoint: oss-cn-zhangjiakou.aliyuncs.com
region: cn-zhangjiakou
bucket: saltbo-blog
dist: public
env:
Expand All @@ -61,17 +61,17 @@ steps:
```yaml
after_success:
- curl -sSf http://uptoc.saltbo.cn/install.sh | sh
- uptoc --endpoint uploader-cn-zhangjiakou.aliyuncs.com --bucket blog-bucket public
- uptoc --region cn-zhangjiakou --bucket blog-bucket public
```

## Args Examples
| driver | bucket | endpoint | endpoint enum |
| driver | bucket | region | region enum |
| ----- | --------- | ------ | ---- |
| oss | ut-uptoc | oss-cn-hangzhou.aliyuncs.com | [Regions and endpoints](https://help.aliyun.com/document_detail/31837.html?spm=a2c4g.11186623.2.12.5fdb25b7xyEcuF#concept-zt4-cvy-5db) |
| qiniu | ut-uptoc | huadong | huadong,huabei,huanan,beimei,xinjiapo |
| cos | ut-uptoc-1255970412 | ap-shanghai | [Regions and endpoints](https://cloud.tencent.com/document/product/436/6224) |
| s3 | ut-uptoc | ap-northeast-1 | [Regions and endpoints](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints) |
| google | ut-uptoc | - | - |
| oss | ut-uptoc | cn-hangzhou | [Regions](https://help.aliyun.com/document_detail/31837.html?spm=a2c4g.11186623.2.12.5fdb25b7xyEcuF#concept-zt4-cvy-5db) |
| cos | ut-uptoc-1255970412 | ap-shanghai | [Regions](https://cloud.tencent.com/document/product/436/6224) |
| qiniu | ut-uptoc | cn-east-1 | [Regions](https://developer.qiniu.com/kodo/manual/4088/s3-access-domainname) |
| google | ut-uptoc | auto | - |
| s3 | ut-uptoc | ap-northeast-1 | [Regions](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints) |


## Contact us
Expand Down
6 changes: 3 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ inputs:
driver:
description: 'specify driver for the cloud platform'
required: true
endpoint:
description: 'specify endpoint of the cloud platform'
region:
description: 'specify region of the cloud platform'
required: true
bucket:
description: 'specify bucket name of the cloud platform'
Expand All @@ -24,6 +24,6 @@ runs:
image: 'Dockerfile'
args:
- ${{ inputs.driver }}
- ${{ inputs.endpoint }}
- ${{ inputs.region }}
- ${{ inputs.bucket }}
- ${{ inputs.dist }}
10 changes: 5 additions & 5 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
const (
// uploader flags
uploaderFlagDriver = "driver"
uploaderFlagEndpoint = "endpoint"
uploaderFlagRegion = "region"
uploaderFlagAccessKey = "access_key"
uploaderFlagAccessSecret = "access_secret"
uploaderFlagBucket = "bucket"
Expand All @@ -41,8 +41,8 @@ var (
Value: "oss",
},
cli.StringFlag{
Name: uploaderFlagEndpoint,
Usage: "specify endpoint of the cloud platform",
Name: uploaderFlagRegion,
Usage: "specify region of the cloud platform",
Required: true,
},
cli.StringFlag{
Expand Down Expand Up @@ -81,11 +81,11 @@ func main() {

func action(c *cli.Context) {
driver := c.String(uploaderFlagDriver)
endpoint := c.String(uploaderFlagEndpoint)
region := c.String(uploaderFlagRegion)
accessKey := c.String(uploaderFlagAccessKey)
accessSecret := c.String(uploaderFlagAccessSecret)
bucketName := c.String(uploaderFlagBucket)
uploadDriver, err := uploader.New(driver, endpoint, accessKey, accessSecret, bucketName)
uploadDriver, err := uploader.New(driver, region, accessKey, accessSecret, bucketName)
if err != nil {
log.Fatalln(err)
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh -l

uptoc --driver "$1" --endpoint "$2" --bucket "$3" "$4"
uptoc --driver "$1" --region "$2" --bucket "$3" "$4"
1 change: 1 addition & 0 deletions uploader/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type Driver interface {
Delete(object string) error
}

// driver => endpoint format template
var supportDrivers = map[string]string{
"cos": "cos.%s.myqcloud.com",
"oss": "oss-%s.aliyuncs.com",
Expand Down

4 comments on commit 0d0e3fd

@eallion
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

还好还看了这次更新,不然老是失败。

@saltbo
Copy link
Collaborator Author

@saltbo saltbo commented on 0d0e3fd May 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, 第一次做开源项目,没有做好兼容。

另外,去你博客看了下,css加载不出来了。好像是因为现在用的http.DetectContentType检测不出text/css。 等我再修复一下

@saltbo
Copy link
Collaborator Author

@saltbo saltbo commented on 0d0e3fd May 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我查了一下阿里云和七牛的源码 都没有看到相关代码 在七牛里看到注释说Mime如果为空服务端会自动判断。

我猜测,他们自己的api应该有这种逻辑,而S3协议里没有,需要手动设置

@saltbo
Copy link
Collaborator Author

@saltbo saltbo commented on 0d0e3fd May 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v1.3.1发布了,你再试一下。抱歉~ @eallion

Please sign in to comment.