Fix preview or viewing of shared animated GIFs (#6386)
* Fix preview or viewing of shared animated GIFs --------- Co-authored-by: Roman Perekhod <rperekhod@owncloud.com>
This commit is contained in:
co-authored by
Roman Perekhod
parent
34909ec1fd
commit
e57e6046d3
@@ -104,6 +104,7 @@ func mapToStorageRequest(r Request) storage.Request {
|
||||
}
|
||||
}
|
||||
|
||||
// IsMimeTypeSupported validate if the mime type is supported
|
||||
func IsMimeTypeSupported(m string) bool {
|
||||
mimeType, _, err := mime.ParseMediaType(m)
|
||||
if err != nil {
|
||||
@@ -112,3 +113,22 @@ func IsMimeTypeSupported(m string) bool {
|
||||
_, supported := SupportedMimeTypes[mimeType]
|
||||
return supported
|
||||
}
|
||||
|
||||
// PrepareRequest prepare the request based on image parameters
|
||||
func PrepareRequest(width, height int, tType, checksum string) (Request, error) {
|
||||
generator, err := GeneratorForType(tType)
|
||||
if err != nil {
|
||||
return Request{}, err
|
||||
}
|
||||
encoder, err := EncoderForType(tType)
|
||||
if err != nil {
|
||||
return Request{}, err
|
||||
}
|
||||
|
||||
return Request{
|
||||
Resolution: image.Rect(0, 0, width, height),
|
||||
Generator: generator,
|
||||
Encoder: encoder,
|
||||
Checksum: checksum,
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user