mirror of https://github.com/cloudreve/Cloudreve
				
				
				
			Fix: missing x-oss-process params in thumb url in public oss bucket
							parent
							
								
									8bb2c2b0c5
								
							
						
					
					
						commit
						b1490a665c
					
				| 
						 | 
				
			
			@ -179,6 +179,7 @@ func (handler Driver) Thumb(ctx context.Context, path string) (*response.Content
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	thumbParam := fmt.Sprintf("image/resize,m_lfit,h_%d,w_%d", thumbSize[1], thumbSize[0])
 | 
			
		||||
	ctx = context.WithValue(ctx, fsctx.ThumbSizeCtx, thumbParam)
 | 
			
		||||
	thumbOption := []oss.Option{oss.Process(thumbParam)}
 | 
			
		||||
	thumbURL, err := handler.signSourceURL(
 | 
			
		||||
		ctx,
 | 
			
		||||
| 
						 | 
				
			
			@ -248,6 +249,12 @@ func (handler Driver) signSourceURL(ctx context.Context, path string, ttl int64,
 | 
			
		|||
			return "", err
 | 
			
		||||
		}
 | 
			
		||||
		sourceURL := cdnURL.ResolveReference(file)
 | 
			
		||||
 | 
			
		||||
		// 如果有缩略图设置
 | 
			
		||||
		if thumbSize, ok := ctx.Value(fsctx.ThumbSizeCtx).(string); ok {
 | 
			
		||||
			sourceURL.RawQuery = "x-oss-process=" + thumbSize
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return sourceURL.String(), nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -17,13 +17,13 @@ func TestCheckSettingValue(t *testing.T) {
 | 
			
		|||
func TestBuildSiteConfig(t *testing.T) {
 | 
			
		||||
	asserts := assert.New(t)
 | 
			
		||||
 | 
			
		||||
	res := BuildSiteConfig(map[string]string{"not exist": ""}, nil)
 | 
			
		||||
	res := BuildSiteConfig(map[string]string{"not exist": ""}, &model.User{})
 | 
			
		||||
	asserts.Equal("", res.Data.(SiteConfig).SiteName)
 | 
			
		||||
 | 
			
		||||
	res = BuildSiteConfig(map[string]string{"siteName": "123"}, nil)
 | 
			
		||||
	res = BuildSiteConfig(map[string]string{"siteName": "123"}, &model.User{})
 | 
			
		||||
	asserts.Equal("123", res.Data.(SiteConfig).SiteName)
 | 
			
		||||
 | 
			
		||||
	res = BuildSiteConfig(map[string]string{"qq_login": "1"}, nil)
 | 
			
		||||
	res = BuildSiteConfig(map[string]string{"qq_login": "1"}, &model.User{})
 | 
			
		||||
	asserts.Equal(true, res.Data.(SiteConfig).QQLogin)
 | 
			
		||||
	asserts.Equal(uint(0), res.Data.(SiteConfig).User.ID)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue