mirror of
https://github.com/go-shiori/shiori.git
synced 2024-09-20 15:06:14 +08:00
For simplicity, thumbnail doesn't need any extension
This commit is contained in:
parent
e65dd220d4
commit
268aeb2b28
|
@ -4,7 +4,6 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"mime"
|
||||
"net/http"
|
||||
nurl "net/url"
|
||||
"os"
|
||||
|
@ -73,25 +72,6 @@ func downloadBookImage(url, dstPath string, timeout time.Duration) error {
|
|||
return err
|
||||
}
|
||||
|
||||
// If destination path doesn't have extension, create it
|
||||
if fp.Ext(dstPath) == "" {
|
||||
cp := resp.Header.Get("Content-Type")
|
||||
if !strings.Contains(cp, "image/") {
|
||||
return fmt.Errorf("%s is not an image", url)
|
||||
}
|
||||
|
||||
exts, err := mime.ExtensionsByType(cp)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create extension: %v", err)
|
||||
}
|
||||
|
||||
if len(exts) == 0 {
|
||||
return fmt.Errorf("unknown content type")
|
||||
}
|
||||
|
||||
dstPath += exts[0]
|
||||
}
|
||||
|
||||
// Create destination file
|
||||
dst, err := os.Create(dstPath)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue