// Copyright 2019 autocareai.com. All rights reserved. // Use of this source code is governed by autocareai.com. package record import ( "github.com/aliyun/aliyun-oss-go-sdk/oss" "m7s.live/engine/v4" //"fmt" "strings" ) func OssGetUrl() string { endpoint := strings.Replace(engine.EngineConfig.OssConfig.Endpoint, "https://", "", -1) return "https://" + engine.EngineConfig.OssConfig.Bucket + "." + endpoint //return "https://dip-dev-test.oss-cn-shanghai.aliyuncs.com" } // UploadOss 上传本地文件到oss func UploadOss(source, file string) (string, error) { //engine.EngineConfig.OssConfig.Endpoint //fmt.Println("oss config1111111111111111111---------------------:",engine.EngineConfig.OssConfig.Bucket,engine.EngineConfig.OssConfig.Endpoint, engine.EngineConfig.OssConfig.AccessKeyId, engine.EngineConfig.OssConfig.AccessKeySecret) client, err := oss.New(engine.EngineConfig.OssConfig.Endpoint, engine.EngineConfig.OssConfig.AccessKeyId, engine.EngineConfig.OssConfig.AccessKeySecret) //client, err := oss.New("oss-cn-shanghai.aliyuncs.com", "LTAI5tMXuRXxUbNuD69ryfUh", "Pujpylo7AJ57pUCJR0NJR6HROLhVYb") if err != nil { return "", err } bucket, err := client.Bucket(engine.EngineConfig.OssConfig.Bucket) //bucket, err := client.Bucket("dip-dev-test") if err != nil { return "", err } err = bucket.PutObjectFromFile(file, source) if err != nil { return "", err } filePath := OssGetUrl() + "/" + file //fmt.Println("oss file------------------------- :",filePath) return filePath, nil }