File uploading on an AWS server looks simple until the files are insurance cards, referral letters and claim attachments that contain patient data. The safe design keeps files off your application servers, out of public buckets and away from users until a malware scan has cleared them.
Startup founders and engineering leaders will find the upload flow we use, how presigned URLs should be scoped, where scanning fits, and the record each upload should leave behind.
What is file uploading on an AWS server?
File uploading on an AWS server is the path a file takes from a user's device into storage your application controls, usually Amazon S3. For patient files, the browser uploads straight to a private bucket through a short-lived presigned URL, a malware scan runs, and only clean files reach the application.
Handling patient documents in your app?
We build upload flows for billing and intake documents that keep files private and scanned.
Amazon S3 documentation describes presigned URLs as bearer tokens that grant access to whoever holds them, limited by the permissions of the IAM principal that created them. A URL signed with temporary credentials expires when those credentials expire, and the AWS CLI or SDKs allow an expiration of up to 7 days.
A presigned URL is therefore a credential. Agnotic Technologies signs one per file, for one object key and one operation, with an expiry measured in minutes rather than days.
Why not upload through your own server?
Uploading through your own server means every byte passes through application instances that then hold patient data in memory or on temporary disk. It works for small files at low volume, but it ties up instances and widens the places where data can leak.
- Capacity: large scans and multi-page PDFs hold connections open and starve other requests.
- Temporary files: copies left on instance disks are easy to forget and hard to audit.
- Timeouts: load balancer and gateway limits cut off slow mobile uploads.
- Scope: the application server ends up needing write access to every bucket path.
Direct upload to S3 keeps the application in charge of who may upload what, without carrying the file itself.
How does a presigned upload flow work?
A presigned upload flow works in two calls: the client asks your API for permission to upload one file, then sends the file directly to S3 using the URL it receives.
- Step 1, request: the signed-in user asks to attach a document to a specific claim, referral or patient record.
- Step 2, check: the API confirms the user may attach files to that record and that the file type and size are allowed.
- Step 3, sign: the API generates a key the user cannot choose, signs a URL for that key with a short expiry and records the request.
- Step 4, upload: the client sends the file to the quarantine bucket with the URL.
- Step 5, scan: the new object triggers a malware scan.
- Step 6, release: a clean file is moved or marked for use, and the upload record becomes available.
The application never accepts a file name or path from the client as the storage key. AWS notes that a presigned upload replaces any existing object with the same key, so random keys stop one user from overwriting another's file.
How should patient files stay out of public buckets?
Patient files stay out of public buckets when public access is blocked at the account level, buckets are private by policy, and every read goes through the application. Changing one setting on one bucket should never be enough to expose files.
Amazon S3 states that new buckets, access points and objects do not allow public access by default, and that S3 Block Public Access settings override bucket policies and object permissions that would allow it. AWS recommends turning on all four Block Public Access settings for the account.
- Account-level block: turn on all four settings so a bucket policy change cannot make files public.
- Separate buckets: one for quarantine, one for clean files, with different access roles.
- Encryption: server-side encryption with a key whose use is logged.
- Reads: the application checks permission, then issues a short-lived download URL or streams the file.
Where does malware scanning fit?
Malware scanning fits between the upload and the first time anyone can open the file. Files land in a quarantine location, a scanner checks them, and only a clean result moves them forward.
GuardDuty Malware Protection for S3 scans newly uploaded objects, and new versions of existing objects, in the buckets you select. By default it publishes scan results to Amazon EventBridge and a CloudWatch namespace, and if tagging is enabled it tags each scanned object with its result.
Whatever scanner you use, the application should read the result before it shows the file. A pending file appears as processing, an infected file is blocked with a clear message, and a failed scan counts as not clean until someone reviews it.
- Clean: the file is released and the record becomes available.
- Threat found: the object is isolated or deleted, and the user is told the file was rejected.
- Scan failed or unsupported: password-protected archives and oversized files are held for review.
- No result: a timeout raises an alert instead of releasing the file by default.
What should each upload record store?
Each upload record should store who uploaded the file, what it was attached to, where it is stored and what the scan said. That record answers support questions and access reviews later.
- Owner and context: user ID, the record the file belongs to and the reason for the upload.
- Storage: bucket, object key, size, the content type checked on the server and a checksum.
- Lifecycle: requested, uploaded, scanned, released or rejected, each with a time.
- Access: every download URL issued, to whom and when it expires.
Do not store the presigned URL itself. It is a credential, and keeping it in logs or tables extends its exposure.
Checking file types and sizes
Checking file types and sizes on the server matters because the browser's declared type is only a hint. A renamed executable can still claim to be a PDF.
- Allow-list types per use: insurance cards as images, claim attachments as PDF, nothing else.
- Check content after upload: read the file signature instead of trusting the extension.
- Set size limits when signing and check the stored object's size again.
- Strip or reprocess images when metadata such as location data is not needed.
Serving files back to users
Serving files back to users should follow the same rules as accepting them: check permission on every request, issue short-lived access, and record who opened what.
- Download URLs are signed per request, for one object, with a short expiry.
- Previews are generated from the clean copy, never from the quarantine bucket.
- Shared links for outside parties, such as a payer reviewer, carry their own expiry and are logged.
- Deleted records take their files with them, according to the retention rules you agreed.
A worked example: an insurance card upload
A worked example: a front desk user at a clinic photographs a patient's insurance card during check-in so the billing team can verify coverage before the visit.
- The app asks the upload API to attach two images, front and back, to the patient's registration record.
- The API checks the user works at that clinic, allows only image types under the size limit, and returns two signed URLs with random keys.
- The phone uploads both images straight to the quarantine bucket, and the record shows them as processing.
- Both scan results come back clean, so the images are released and the billing work queue shows a new card to verify.
- A biller opens the card later through a download link signed for that request alone.
If the user retries after a dropped connection, the app asks for new URLs rather than reusing the old ones. The upload record shows both attempts, which helps support explain what happened.
Large files and unreliable connections
Large files and unreliable connections call for multipart uploads and a resume path, especially for scanned records and reports uploaded from clinics with weak networks.
- Split large files into parts, each uploaded with its own signed URL, and complete the upload from the API.
- Let the client resume from the last finished part instead of starting again.
- Clean up abandoned multipart uploads with a lifecycle rule so partial data does not sit in the bucket.
- Show progress per file so staff do not close the page mid-upload.
Who should be able to delete or replace a file?
Only named roles should delete or replace a file, and every change should be recorded, because a document attached to a claim or a referral may be needed as evidence later.
- Replace means a new upload linked to the old one, never an overwrite of the same key.
- Deleting a file removes access first, then removes the object according to retention rules.
- Bucket versioning keeps prior versions recoverable for a defined period.
- Every deletion carries a reason and the name of the person who made it.
What are the common mistakes with file uploading on AWS?
The common mistakes with file uploading on AWS come from treating the URL as a convenience rather than a credential, and from releasing files before anything has checked them.
- Long expiries: URLs valid for days get forwarded, logged and reused.
- Client-chosen keys: a user picks a path and overwrites another user's document.
- One bucket for everything: quarantine and clean files share permissions, so the scan is only advisory.
- Public read for convenience: a bucket opened for a preview feature exposes every file in it.
- No scan result check: the application shows files as soon as the upload completes.
What does a secure upload flow mean for your build plan?
A secure upload flow adds a signing API, two buckets, a scan step, an upload record and download URLs. Each piece is small, but the order of operations has to be designed and tested as one flow.
- List every place users upload files and the types each one needs.
- Decide expiry times for upload and download URLs with security and support staff.
- Choose the scanner and define what happens on each result.
- Plan retention: how long files are kept and how they are deleted with the record.
How does Agnotic build secure upload flows?
Agnotic builds upload flows for billing, intake and referral documents: the signing API, private buckets, scanning, the upload record and secure downloads, wired into your existing application and tested with real file types.
Keep patient documents private from the first byte
Presigned uploads, scanning and an upload record, built into your product.
Related reading on Agnotic
Cloud security, AWS and software engineering reading.


