Skip to content

g1ave/go-cloud-disk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-cloud-disk

How to use goctl

Installation

go install github.com/zeromicro/go-zero/tools/goctl@latest

Quick start

goctl api new core

Generate handler file and logic file according .api file

goctl api go core.api -dir . -style gozero

File upload (Tencent Cloud COS)

https://console.cloud.tencent.com/cos

Install SDK

go get -u github.com/tencentyun/cos-go-sdk-v5

Upload Object Example

package main

import (
    "context"
    "github.com/tencentyun/cos-go-sdk-v5"
    "net/http"
    "net/url"
    "os"
)

func main() {
    u, _ := url.Parse("https://examplebucket-1250000000.cos.ap-guangzhou.myqcloud.com")
    b := &cos.BaseURL{BucketURL: u}
    client := cos.NewClient(b, &http.Client{
        Transport: &cos.AuthorizationTransport{
            SecretID: "YOUR-COS-SECRET-ID",
            SecretKey: "YOUR-COS-SECRET-KEY",
        },
    })

    key := "exampleobject"

    _, _, err := client.Object.Upload(
        context.Background(), key, "localfile", nil,
    )
    if err != nil {
        panic(err)
    }
}

About

A simple cloud-disk project based on go-zero.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages