Commit 348b56ab by 周业恒

Update upload.go

parent 50ae7908
Pipeline #15358 passed with stages
in 39 seconds
...@@ -6,6 +6,10 @@ import ( ...@@ -6,6 +6,10 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"github.com/aliyun/aliyun-oss-go-sdk/oss"
"github.com/astaxie/beego/orm"
"github.com/rocketlaunchr/go-pool"
"github.com/xxjwxc/gowp/workpool"
"image" "image"
"image/jpeg" "image/jpeg"
"image/png" "image/png"
...@@ -22,19 +26,15 @@ import ( ...@@ -22,19 +26,15 @@ import (
"regexp" "regexp"
"strconv" "strconv"
"strings" "strings"
"sync"
"time" "time"
"github.com/aliyun/aliyun-oss-go-sdk/oss"
"github.com/astaxie/beego/orm"
"github.com/rocketlaunchr/go-pool"
"github.com/xxjwxc/gowp/workpool"
) )
var ( var (
WEBURL string = "http://offcn-live-svc" WEBURL string = "http://offcn-live-svc"
//WEBURL string = "https://live.offcncloud.com" //WEBURL string = "https://test-live.offcncloud.com"
client *http.Client once sync.Once
token string syncPool pool.Pool
) )
const docUrl string = "http://doc.offcncloud.com/" const docUrl string = "http://doc.offcncloud.com/"
...@@ -335,13 +335,13 @@ func webToken() (*http.Client, string, error) { ...@@ -335,13 +335,13 @@ func webToken() (*http.Client, string, error) {
if err != nil { if err != nil {
return &http.Client{}, "", err return &http.Client{}, "", err
} }
log.Println("获取token == ", map2)
if _, ok := map2["code"]; !ok { if _, ok := map2["code"]; !ok {
return &http.Client{}, "", errors.New("登录失败") return &http.Client{}, "", errors.New("登录失败")
} }
if _, ok := map2["code"].(float64); !ok { if _, ok := map2["code"].(float64); !ok {
return &http.Client{}, "", errors.New("登录失败") return &http.Client{}, "", errors.New("登录失败")
} }
if int(map2["code"].(float64)) == 200 { if int(map2["code"].(float64)) == 200 {
//登录成功获取token //登录成功获取token
t_res, err := client.Get(WEBURL + "/web/admin") t_res, err := client.Get(WEBURL + "/web/admin")
...@@ -460,6 +460,7 @@ func CreateFileDataBase(room_file map[string]interface{}) error { ...@@ -460,6 +460,7 @@ func CreateFileDataBase(room_file map[string]interface{}) error {
log.Println(err) log.Println(err)
return err return err
} }
log.Println("room_files response = ", map2) log.Println("room_files response = ", map2)
if _, ok := map2["code"]; !ok { if _, ok := map2["code"]; !ok {
...@@ -526,6 +527,7 @@ func pdfThumbnail(objectPath string, file *zip.File, bucket *oss.Bucket) ([]inte ...@@ -526,6 +527,7 @@ func pdfThumbnail(objectPath string, file *zip.File, bucket *oss.Bucket) ([]inte
defer fc1.Close() defer fc1.Close()
return imageInfo, bucket.PutObject(objectPathName+fileName, fc1) return imageInfo, bucket.PutObject(objectPathName+fileName, fc1)
} }
func uploadPacked(bucket *oss.Bucket, filename, contentHash, func uploadPacked(bucket *oss.Bucket, filename, contentHash,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment