Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a preservename header. #248

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ Create an issue on GitHub, please include the following (if one of them is not a

## Feature requests

Create an issue on GitHub, please include the following:
Create a discussion on GitHub, please include the following:

- Breif explanation of the feature in the title (very breif please)
- How it would work (detailed, but optional)
- How it would work (Be detailed!)

## Pull Requests (contributions to the codebase)

Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
"build:next": "next build",
"build:schema": "prisma generate --schema=prisma/schema.prisma",
"format": "prettier --write ./src/**/*.{ts,tsx} ./*.{md,js,json,yml}",
"migrate:dev": "prisma migrate dev --create-only",
"migrate": "npm-run-all -s \"migrate:* {*}\" --",
"migrate:dev": "prisma migrate dev --create-only --name=$(echo ${0} | sed 's/ /_/g') 1>&1 1>&2 | grep -E \"[0-9]\\{10,\\}(_[a-zA-z]*)*\" -o > .tmp.sql",
"migrate:postDev": "prisma migrate diff --from-schema-datamodel prisma/schema.prisma --to-schema-datasource prisma/schema.prisma --shadow-database-url $DATABASE_URL > ./prisma/migrations/$(cat .tmp.sql & rm .tmp.sql)/down.sql",
"start": "node dist",
"lint": "next lint",
"docker:run": "docker-compose up -d",
Expand Down
4 changes: 4 additions & 0 deletions prisma/migrations/20221217020248_add_ogfile_name/down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

[*] Changed the `Image` table
[-] Removed column `ogFile`

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Image" ADD COLUMN "ogFile" TEXT;
1 change: 1 addition & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ enum ImageFormat {
model Image {
id Int @id @default(autoincrement())
file String
ogFile String?
mimetype String @default("image/png")
created_at DateTime @default(now())
expires_at DateTime?
Expand Down
4 changes: 4 additions & 0 deletions src/server/decorators/dbFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ function dbFileDecorator(fastify: FastifyInstance, _, done) {

this.header('Content-Length', size);
this.header('Content-Type', image.mimetype);
this.header(
'Content-Disposition',
`inline; name="${image.ogFile ?? image.file}" filename="${image.file}"`
);
return this.send(data);
}
}
Expand Down