73 lines
2.2 KiB
Go
73 lines
2.2 KiB
Go
/*
|
|
|
|
Copyright (c) [2023] [pcm]
|
|
[pcm-coordinator] is licensed under Mulan PSL v2.
|
|
You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
You may obtain a copy of Mulan PSL v2 at:
|
|
http://license.coscl.org.cn/MulanPSL2
|
|
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
|
EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
|
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
|
See the Mulan PSL v2 for more details.
|
|
|
|
*/
|
|
|
|
package image
|
|
|
|
import (
|
|
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
|
|
"net/http"
|
|
)
|
|
|
|
func UploadDataSetHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
////file, fileHeader, err := r.FormFile("file")
|
|
////if err != nil {
|
|
//// return
|
|
////}
|
|
//AK := "your_access_key"
|
|
//SK := "your_secret_key"
|
|
//cred := aws.Credentials{AccessKeyID: AK, SecretAccessKey: SK}
|
|
//
|
|
//uploader := manager.NewUploader(client)
|
|
//endpointURL := "http://10.105.24.4:7480"
|
|
//
|
|
//customResolver := aws.EndpointResolverWithOptionsFunc(func(service, region string, options ...interface{}) (aws.Endpoint, error) {
|
|
// return aws.Endpoint{
|
|
// URL: endpointURL,
|
|
// }, nil
|
|
//})
|
|
//
|
|
//client := s3.NewFromConfig(aws.Config{Credentials: credentials.NewAccessKeyCredential()})
|
|
//cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithEndpointResolverWithOptions(customResolver))
|
|
//if err != nil {
|
|
// panic(err)
|
|
//}
|
|
//
|
|
//s3Client := s3.NewFromConfig(cfg, func(options *s3.Options) {
|
|
// options.UsePathStyle = true
|
|
//})
|
|
// 上传文件
|
|
//uploader := manager.NewUploader(s3Client)
|
|
//bucket := "pcm"
|
|
//key := fileHeader.Filename
|
|
//result, err := uploader.Upload(context.TODO(), &s3.PutObjectInput{
|
|
// Bucket: &bucket,
|
|
// Key: &key,
|
|
// Body: file,
|
|
//})
|
|
//println(result)
|
|
//output, err := s3Client.ListObjectsV2(context.TODO(), &s3.ListObjectsV2Input{
|
|
// Bucket: aws.String("my-bucket"),
|
|
//})
|
|
//if err != nil {
|
|
// log.Fatal(err)
|
|
//}
|
|
//
|
|
//log.Println("first page results:")
|
|
//for _, object := range output.Contents {
|
|
// log.Printf("key=%s size=%d", aws.ToString(object.Key), object.Size)
|
|
//}
|
|
}
|
|
}
|