🐛 Provide a way to bypass nexus and serving content to prevent nexus reverse proxy issue
This commit is contained in:
@ -26,12 +26,7 @@ func openAttachment(c *fiber.Ctx) error {
|
||||
return fiber.NewError(fiber.StatusNotFound, "file is in uploading progress, please wait until all chunk uploaded")
|
||||
}
|
||||
|
||||
var destMap map[string]any
|
||||
if metadata.Destination == models.AttachmentDstTemporary {
|
||||
destMap = viper.GetStringMap("destinations.temporary")
|
||||
} else {
|
||||
destMap = viper.GetStringMap("destinations.permanent")
|
||||
}
|
||||
destMap := viper.GetStringMap(fmt.Sprintf("destinations.%d", metadata.Destination))
|
||||
|
||||
var dest models.BaseDestination
|
||||
rawDest, _ := jsoniter.Marshal(destMap)
|
||||
@ -41,10 +36,19 @@ func openAttachment(c *fiber.Ctx) error {
|
||||
case models.DestinationTypeLocal:
|
||||
var destConfigured models.LocalDestination
|
||||
_ = jsoniter.Unmarshal(rawDest, &destConfigured)
|
||||
if len(destConfigured.AccessBaseURL) > 0 && !c.QueryBool("direct", false) {
|
||||
// This will drop all query parameters,
|
||||
// for not it's okay because the openAttachment api won't take any query parameters
|
||||
return c.Redirect(fmt.Sprintf(
|
||||
"%s%s?direct=true",
|
||||
destConfigured.AccessBaseURL,
|
||||
c.Path(),
|
||||
), fiber.StatusMovedPermanently)
|
||||
}
|
||||
if len(metadata.MimeType) > 0 {
|
||||
c.Set(fiber.HeaderContentType, metadata.MimeType)
|
||||
}
|
||||
return c.SendFile(filepath.Join(destConfigured.Path, metadata.Uuid), false)
|
||||
return c.SendFile(filepath.Join(destConfigured.Path, metadata.Uuid))
|
||||
case models.DestinationTypeS3:
|
||||
var destConfigured models.S3Destination
|
||||
_ = jsoniter.Unmarshal(rawDest, &destConfigured)
|
||||
|
Reference in New Issue
Block a user