-
-
Notifications
You must be signed in to change notification settings - Fork 0
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
File Uploads #149
Open
supermomme
wants to merge
15
commits into
development
Choose a base branch
from
feature/123-anhänge-für-die-tn-bei-der-anmeldung
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
The head ref may contain hidden characters: "feature/123-anh\u00E4nge-f\u00FCr-die-tn-bei-der-anmeldung"
Open
File Uploads #149
Changes from 12 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
05f2030
add local file provider
supermomme 56ebc32
add UnterveranstalltungDocument + add manage document in unterveranst…
supermomme 4211787
add document list in detail-view
supermomme 28697af
add filename to File
supermomme 65a8be5
add documents in public ausschreibung
supermomme 2e52bd7
rename fileProvider
supermomme f7a6994
WIP azure file provider
supermomme 1567623
restructure file config
supermomme 9c9236c
squash file migrations
supermomme fadff81
restrict file create endpoint
supermomme e956106
improve file security
supermomme 4b167ba
change requests
supermomme 9f29ad9
Merge remote-tracking branch 'origin/development' into feature/123-an…
supermomme f6adb63
fix migration
supermomme f4fc608
remove todo + remove file-test
supermomme File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,3 +89,4 @@ typings/ | |
reports | ||
**/tsconfig.tsbuildinfo | ||
tsconfig.tsbuildinfo | ||
uploads/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...a/migrations/20240418213610_add_file_and_unterveranstaltung_document_models/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
-- CreateEnum | ||
CREATE TYPE "FileProvider" AS ENUM ('LOCAL', 'AZURE'); | ||
|
||
-- CreateTable | ||
CREATE TABLE "UnterveranstaltungDocument" ( | ||
"id" SERIAL NOT NULL, | ||
"name" TEXT NOT NULL, | ||
"description" TEXT, | ||
"unterveranstaltungId" INTEGER NOT NULL, | ||
"fileId" TEXT NOT NULL, | ||
|
||
CONSTRAINT "UnterveranstaltungDocument_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "File" ( | ||
"id" TEXT NOT NULL, | ||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"uploaded" BOOLEAN NOT NULL DEFAULT false, | ||
"uploadedAt" TIMESTAMP(3), | ||
"provider" "FileProvider" NOT NULL, | ||
"key" TEXT NOT NULL, | ||
"filename" TEXT, | ||
"mimetype" TEXT, | ||
|
||
CONSTRAINT "File_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "UnterveranstaltungDocument_fileId_key" ON "UnterveranstaltungDocument"("fileId"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "File_id_key" ON "File"("id"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "File_key_key" ON "File"("key"); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "UnterveranstaltungDocument" ADD CONSTRAINT "UnterveranstaltungDocument_unterveranstaltungId_fkey" FOREIGN KEY ("unterveranstaltungId") REFERENCES "Unterveranstaltung"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "UnterveranstaltungDocument" ADD CONSTRAINT "UnterveranstaltungDocument_fileId_fkey" FOREIGN KEY ("fileId") REFERENCES "File"("id") ON DELETE RESTRICT ON UPDATE CASCADE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { BlobServiceClient, StorageSharedKeyCredential } from '@azure/storage-blob' | ||
|
||
import config from './config' | ||
|
||
const isAzureConfigured = | ||
config.fileProviders.AZURE.account !== '' && | ||
config.fileProviders.AZURE.accountKey !== '' && | ||
config.fileProviders.AZURE.container !== '' | ||
|
||
async function init() { | ||
if (!isAzureConfigured) return null | ||
const account = config.fileProviders.AZURE.account | ||
const accountKey = config.fileProviders.AZURE.accountKey | ||
const sharedKeyCredential = new StorageSharedKeyCredential(account, accountKey) | ||
|
||
const blobServiceClient = new BlobServiceClient(`https://${account}.blob.core.windows.net`, sharedKeyCredential) | ||
|
||
// Check if container exists, if not create it | ||
const containerClient = blobServiceClient.getContainerClient(config.fileProviders.AZURE.container) | ||
if (!(await containerClient.exists())) await containerClient.create() | ||
return blobServiceClient | ||
} | ||
|
||
export let azureStorage: BlobServiceClient | null = null | ||
|
||
init() | ||
.then((blobServiceClient) => (azureStorage = blobServiceClient)) | ||
.catch((e) => { | ||
console.error('Failed to initialize Azure Blob Storage', e) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wozu diese extra Entität? Verknüpfung Unterveranstaltung -> File reicht in meinen Augen, dann als Array einfach
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Der Gedanke hier ist, dass Dokumente auch einen beschreibenden Namen enthalten kann. Theoretisch könnte man das auch in File packen.