mirror of
https://github.com/imgproxy/imgproxy.git
synced 2025-10-10 20:22:31 +02:00
Add Content-Disposition filename customization
This commit is contained in:
@@ -125,6 +125,8 @@ type processingOptions struct {
|
||||
PreferWebP bool
|
||||
EnforceWebP bool
|
||||
|
||||
Filename string
|
||||
|
||||
UsedPresets []string
|
||||
}
|
||||
|
||||
@@ -635,6 +637,16 @@ func applyCacheBusterOption(po *processingOptions, args []string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func applyFilenameOption(po *processingOptions, args []string) error {
|
||||
if len(args) > 1 {
|
||||
return fmt.Errorf("Invalid filename arguments: %v", args)
|
||||
}
|
||||
|
||||
po.Filename = args[0]
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func applyProcessingOption(po *processingOptions, name string, args []string) error {
|
||||
switch name {
|
||||
case "format", "f", "ext":
|
||||
@@ -709,6 +721,10 @@ func applyProcessingOption(po *processingOptions, name string, args []string) er
|
||||
if err := applyCacheBusterOption(po, args); err != nil {
|
||||
return err
|
||||
}
|
||||
case "filename", "fn":
|
||||
if err := applyFilenameOption(po, args); err != nil {
|
||||
return err
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("Unknown processing option: %s", name)
|
||||
}
|
||||
|
Reference in New Issue
Block a user