feat: add POST /asset/upload-and-record endpoint for digital asset upload (BDMS-828)#683
Merged
Merged
Conversation
Adds a single endpoint that uploads a digital asset to GCS and records it in the database in one step. Accepts multipart/form-data with the file, a required thing_id, and optional label/name fields. - Validates file type (JPEG, PNG, GIF, WebP, TIFF, PDF, plain text) - Enforces a 250 MB size limit - Guards against duplicate uploads for the same file + thing combination - Creates Asset DB record and AssetThingAssociation in one transaction - Also fixes a pre-existing bug in audit_helper where AUTHENTIK_DISABLE_AUTHENTICATION=1 caused a TypeError by returning True instead of a user claims dict Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
jirhiker
approved these changes
Jun 4, 2026
Member
|
looks great! |
This was referenced Jun 8, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adds a single endpoint that uploads a digital asset to GCS and records
it in the database in one step. Accepts multipart/form-data with the
file, a required thing_id, and optional label/name fields.
Why
POST /asset/upload(GCS only) thenPOST /asset(DB only), forcingthe UI to chain requests and handle intermediate state
the GCS upload and database record creation atomically
How
POST /asset/upload-and-recordtoapi/asset.pywith multipartform fields:
file(required),thing_id(required),labelandname(optional)TIFF, PDF, and plain text; rejects all others with 400
the same Thing, the existing asset record is returned instead of
creating a duplicate
AssetDB record andAssetThingAssociationin onetransaction using existing
gcs_upload,check_asset_exists, andaudit_addhelpersaudit_helper.pywhereAUTHENTIK_DISABLE_AUTHENTICATION=1caused aTypeErrorby returningTrueinstead of a user claims dictNotes
audit_helper.pyfix affects all endpoints that callaudit_add,not just this one — it is a defensive guard (
isinstance(user, dict))that is a no-op in production where auth is always enabled
/asset/uploadandPOST /assettwo-step endpoints areunchanged and still available
/docs-auth) — uploaded a JPEG (88,964bytes), file was stored in GCS as
test_49e37e503db40eeb09e1e4d0f7c76c8c.JPG, DB record created withid=1, uri=https://storage.cloud.google.com/ocotillo/uploads/test_49e37e503db40eeb09e1e4d0f7c76c8c.JPG,
release_status=draft, storage_service=gcs