mirror of
				https://github.com/cloudreve/cloudreve.git
				synced 2025-10-31 08:39:10 +08:00 
			
		
		
		
	Fix: S3 adaption for minio
This commit is contained in:
		
							
								
								
									
										2
									
								
								assets
									
									
									
									
									
								
							
							
								
								
								
								
								
							
						
						
									
										2
									
								
								assets
									
									
									
									
									
								
							 Submodule assets updated: 8f2a9c3d81...f342a2a777
									
								
							| @ -3,6 +3,7 @@ package model | ||||
| import ( | ||||
| 	"encoding/gob" | ||||
| 	"encoding/json" | ||||
| 	"fmt" | ||||
| 	"net/url" | ||||
| 	"path" | ||||
| 	"path/filepath" | ||||
| @ -239,7 +240,7 @@ func (policy *Policy) GetUploadURL() string { | ||||
| 		return policy.Server | ||||
| 	} | ||||
|  | ||||
| 	var controller *url.URL | ||||
| 	controller, _ := url.Parse("") | ||||
| 	switch policy.Type { | ||||
| 	case "local", "onedrive": | ||||
| 		return "/api/v3/file/upload" | ||||
| @ -251,9 +252,17 @@ func (policy *Policy) GetUploadURL() string { | ||||
| 		return policy.Server | ||||
| 	case "upyun": | ||||
| 		return "https://v0.api.upyun.com/" + policy.BucketName | ||||
| 	default: | ||||
| 		controller, _ = url.Parse("") | ||||
| 	case "s3": | ||||
| 		if policy.Server == "" { | ||||
| 			return fmt.Sprintf("https://%s.s3.%s.amazonaws.com/", policy.BucketName, | ||||
| 				policy.OptionsSerialized.Region) | ||||
| 		} | ||||
|  | ||||
| 		if !strings.Contains(policy.Server, policy.BucketName) { | ||||
| 			controller, _ = url.Parse("/" + policy.BucketName) | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	return server.ResolveReference(controller).String() | ||||
| } | ||||
|  | ||||
|  | ||||
| @ -62,6 +62,7 @@ func (handler *Driver) InitS3Client() error { | ||||
| 			Region:           &handler.Policy.OptionsSerialized.Region, | ||||
| 			S3ForcePathStyle: aws.Bool(false), | ||||
| 		}) | ||||
|  | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| 		} | ||||
|  | ||||
| @ -110,6 +110,7 @@ func COSCallback(c *gin.Context) { | ||||
|  | ||||
| // S3Callback S3上传完成客户端回调 | ||||
| func S3Callback(c *gin.Context) { | ||||
| 	c.Header("Access-Control-Allow-Origin", "*") | ||||
| 	var callbackBody callback.S3Callback | ||||
| 	if err := c.ShouldBindQuery(&callbackBody); err == nil { | ||||
| 		res := callbackBody.PreProcess(c) | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 HFO4
					HFO4