🐛 Bug fixes

This commit is contained in:
LittleSheep 2024-06-01 22:15:41 +08:00
parent 2b131982b8
commit a1aa418496
3 changed files with 9 additions and 10 deletions

8
.idea/workspace.xml generated
View File

@ -4,13 +4,7 @@
<option name="autoReloadType" value="ALL" /> <option name="autoReloadType" value="ALL" />
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="18dd0d68-b4b8-40db-9734-9119b5c848bd" name="更改" comment=":bug: Fix uuid duplicate when link exists"> <list default="true" id="18dd0d68-b4b8-40db-9734-9119b5c848bd" name="更改" comment=":bug: Fix uuid duplicate when link exists" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/models/attachments.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/models/attachments.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/server/attachments_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/server/attachments_api.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/services/attachments.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/services/attachments.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/settings.toml" beforeDir="false" afterPath="$PROJECT_DIR$/settings.toml" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />

View File

@ -40,7 +40,11 @@ func openAttachment(c *fiber.Ctx) error {
case models.DestinationTypeLocal: case models.DestinationTypeLocal:
var destConfigured models.LocalDestination var destConfigured models.LocalDestination
_ = jsoniter.Unmarshal(rawDest, &destConfigured) _ = jsoniter.Unmarshal(rawDest, &destConfigured)
return c.SendFile(filepath.Join(destConfigured.Path, metadata.Uuid)) if len(metadata.MimeType) > 0 {
c.Set(fiber.HeaderContentType, metadata.MimeType)
}
return c.SendFile(filepath.Join(destConfigured.Path, metadata.Uuid), false)
case models.DestinationTypeS3: case models.DestinationTypeS3:
var destConfigured models.S3Destination var destConfigured models.S3Destination
_ = jsoniter.Unmarshal(rawDest, &destConfigured) _ = jsoniter.Unmarshal(rawDest, &destConfigured)
@ -52,6 +56,7 @@ func openAttachment(c *fiber.Ctx) error {
destConfigured.Endpoint, destConfigured.Endpoint,
url.QueryEscape(filepath.Join(destConfigured.Path, metadata.Uuid)), url.QueryEscape(filepath.Join(destConfigured.Path, metadata.Uuid)),
)) ))
default: default:
return fmt.Errorf("invalid destination: unsupported protocol %s", destParsed.Type) return fmt.Errorf("invalid destination: unsupported protocol %s", destParsed.Type)
} }

View File

@ -26,12 +26,12 @@ access_token_duration = 300
refresh_token_duration = 2592000 refresh_token_duration = 2592000
[database] [database]
dsn = "host=localhost dbname=hy_paperclip port=5432 sslmode=disable" dsn = "host=localhost user=postgres password=password dbname=hy_paperclip port=5432 sslmode=disable"
prefix = "paperclip_" prefix = "paperclip_"
[destinations.local] [destinations.local]
type = "local" type = "local"
path = "uploads" path = "/uploads"
[destinations.s3] [destinations.s3]
type = "s3" type = "s3"