mirror of
				https://github.com/cloudreve/cloudreve.git
				synced 2025-10-31 16:49:03 +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 ( | import ( | ||||||
| 	"encoding/gob" | 	"encoding/gob" | ||||||
| 	"encoding/json" | 	"encoding/json" | ||||||
|  | 	"fmt" | ||||||
| 	"net/url" | 	"net/url" | ||||||
| 	"path" | 	"path" | ||||||
| 	"path/filepath" | 	"path/filepath" | ||||||
| @ -239,7 +240,7 @@ func (policy *Policy) GetUploadURL() string { | |||||||
| 		return policy.Server | 		return policy.Server | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	var controller *url.URL | 	controller, _ := url.Parse("") | ||||||
| 	switch policy.Type { | 	switch policy.Type { | ||||||
| 	case "local", "onedrive": | 	case "local", "onedrive": | ||||||
| 		return "/api/v3/file/upload" | 		return "/api/v3/file/upload" | ||||||
| @ -251,9 +252,17 @@ func (policy *Policy) GetUploadURL() string { | |||||||
| 		return policy.Server | 		return policy.Server | ||||||
| 	case "upyun": | 	case "upyun": | ||||||
| 		return "https://v0.api.upyun.com/" + policy.BucketName | 		return "https://v0.api.upyun.com/" + policy.BucketName | ||||||
| 	default: | 	case "s3": | ||||||
| 		controller, _ = url.Parse("") | 		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() | 	return server.ResolveReference(controller).String() | ||||||
| } | } | ||||||
|  |  | ||||||
|  | |||||||
| @ -62,6 +62,7 @@ func (handler *Driver) InitS3Client() error { | |||||||
| 			Region:           &handler.Policy.OptionsSerialized.Region, | 			Region:           &handler.Policy.OptionsSerialized.Region, | ||||||
| 			S3ForcePathStyle: aws.Bool(false), | 			S3ForcePathStyle: aws.Bool(false), | ||||||
| 		}) | 		}) | ||||||
|  |  | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			return err | 			return err | ||||||
| 		} | 		} | ||||||
|  | |||||||
| @ -110,6 +110,7 @@ func COSCallback(c *gin.Context) { | |||||||
|  |  | ||||||
| // S3Callback S3上传完成客户端回调 | // S3Callback S3上传完成客户端回调 | ||||||
| func S3Callback(c *gin.Context) { | func S3Callback(c *gin.Context) { | ||||||
|  | 	c.Header("Access-Control-Allow-Origin", "*") | ||||||
| 	var callbackBody callback.S3Callback | 	var callbackBody callback.S3Callback | ||||||
| 	if err := c.ShouldBindQuery(&callbackBody); err == nil { | 	if err := c.ShouldBindQuery(&callbackBody); err == nil { | ||||||
| 		res := callbackBody.PreProcess(c) | 		res := callbackBody.PreProcess(c) | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 HFO4
					HFO4