Skip to content

feat(files): persist uploaded files and associate them with conversations (#42) - #319

Open
Hustler490 wants to merge 1 commit into
AyinkxLab:mainfrom
Hustler490:feat/42-persist-uploads
Open

Hustler490 wants to merge 1 commit into
AyinkxLab:mainfrom
Hustler490:feat/42-persist-uploads

Conversation

@Hustler490

Copy link
Copy Markdown

Closes #42.

What

Persists uploaded files on disk and records them in a new files table so they can be listed, downloaded, attached to a conversation, and re-analyzed later.

Model + schema

  • New UploadedFile model (app/models/uploaded_file.py, table files): id, workspace_id, user_id, original_name, stored_name, size, content_type, created_at plus an optional conversation_id association.
  • Alembic migration e2d3c4b5a6f7_add_files_table.py (upgrade creates the table + indexes; downgrade drops it). tests/test_migrations.py head assertion updated to the new revision.

Storage + validation (app/services/uploads.py)

  • Files are written under the configurable UPLOAD_FOLDER (app/config.py; a throwaway temp dir in testing) with a random stored_name.
  • Extension, UTF-8, and size checks reuse the /tools/analyze allowlist and 200k-char cap (ALLOWED_EXTENSIONS/MAX_UPLOAD_CHARS are now defined once and shared).

Routes (/tools/files)

  • POST /tools/files upload, GET /tools/files list, GET /tools/files/<id> metadata, GET /tools/files/<id>/download, POST /tools/files/<id>/attach (associate with a conversation), POST /tools/files/<id>/reanalyze. All are owner-scoped (user_id == current_user.id) and 404 for other users.

Tests (tests/test_files_persistence.py)

Upload (metadata + on-disk bytes), retrieval, download, attach, re-analyze, unsupported-type rejection, and owner-only access.

Acceptance criteria

  • New files table with the requested columns.
  • Uploads stored under a configurable UPLOAD_FOLDER with random names and validated extensions.
  • Files can be attached to a conversation and re-analyzed later.
  • Size/type checks reuse /tools/analyze validation.
  • Tests cover upload, retrieval, download, and owner-only access.

@drips-wave

drips-wave Bot commented Sep 29, 2026

Copy link
Copy Markdown

@Hustler490 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Hustler490
Hustler490 force-pushed the feat/42-persist-uploads branch from 589a0b2 to 9be7a2b Compare October 4, 2026 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Persist uploaded files and associate with conversations

2 participants