59 lines
1.7 KiB
Go
59 lines
1.7 KiB
Go
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)
|
|
//}
|
|
}
|
|
}
|