|
|
|
@ -450,17 +450,7 @@ func (client *Client) makeBatchDeleteRequestsBody(files []string) string {
|
|
|
|
|
// GetThumbURL 获取给定尺寸的缩略图URL
|
|
|
|
|
func (client *Client) GetThumbURL(ctx context.Context, dst string, w, h uint) (string, error) {
|
|
|
|
|
dst = strings.TrimPrefix(dst, "/")
|
|
|
|
|
var (
|
|
|
|
|
cropOption string
|
|
|
|
|
requestURL string
|
|
|
|
|
)
|
|
|
|
|
if client.Endpoints.isInChina {
|
|
|
|
|
cropOption = "large"
|
|
|
|
|
requestURL = client.getRequestURL("root:/"+dst+":/thumbnails/0") + "/" + cropOption
|
|
|
|
|
} else {
|
|
|
|
|
cropOption = fmt.Sprintf("c%dx%d_Crop", w, h)
|
|
|
|
|
requestURL = client.getRequestURL("root:/"+dst+":/thumbnails") + "?select=" + cropOption
|
|
|
|
|
}
|
|
|
|
|
requestURL := client.getRequestURL("root:/"+dst+":/thumbnails/0") + "/large"
|
|
|
|
|
|
|
|
|
|
res, err := client.requestWithStr(ctx, "GET", requestURL, "", 200)
|
|
|
|
|
if err != nil {
|
|
|
|
@ -481,7 +471,7 @@ func (client *Client) GetThumbURL(ctx context.Context, dst string, w, h uint) (s
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if len(thumbRes.Value) == 1 {
|
|
|
|
|
if res, ok := thumbRes.Value[0][cropOption]; ok {
|
|
|
|
|
if res, ok := thumbRes.Value[0]["large"]; ok {
|
|
|
|
|
return res.(map[string]interface{})["url"].(string), nil
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|