"github.com/volcengine/ve-tos-golang-sdk/v2/tos"
func checkErr(err error) {
if ServerErr, ok := err.(*tos.TosServerError); ok {
fmt.Println("Error:", ServerErr.Error())
fmt.Println("Request ID:", ServerErr.RequestID)
fmt.Println("Response Status Code:", ServerErr.StatusCode)
fmt.Println("Response Header:", ServerErr.Header)
fmt.Println("Response Err Code:", ServerErr.Code)
fmt.Println("Response Err Msg:", ServerErr.Message)
} else if clientErr, ok := err.(*tos.TosClientError); ok {
fmt.Println("Error:", clientErr.Error())
fmt.Println("Client Cause Err:", clientErr.Cause.Error())
fmt.Println("Error:", err)
accessKey = "*** Provide your access key ***"
secretKey = "*** Provide your secret key ***"
endpoint = "https://tos-cn-beijing.volces.com"
bucketName = "*** Provide your bucket name ***"
objectKey = "example_dir/example.txt"
ctx = context.Background()
fileName = "/usr/local/testfile.txt"
client, err := tos.NewClientV2(endpoint, tos.WithRegion(region), tos.WithCredentials(tos.NewStaticCredentials(accessKey, secretKey)))
respTempUrl,errURL:=client.PreSignedURL(&tos.PreSignedURLInput{
HTTPMethod: enum.HttpMethodGet,
fmt.Println(respTempUrl.SignedUrl)