mirror of https://github.com/interlegis/sapl.git
Browse Source
- MetadataFileField.generate_filename: substitutes a UUID for the original filename in the upload_to path so new files land at a stable, unguessable storage path (e.g. sapl/public/norma/2025/9395/<uuid>.pdf). For replacements the existing UUID is reused; OverwriteStorage replaces bytes in-place and the public /documentos/<uuid>/ URL never changes. A fresh UUID is stashed on the instance (_pending_uuid_<field>) and wired into the new FileMetadata row in pre_save so FileMetadata.uuid always matches the path. - pre_save Case 2 fix: skip explicit default_storage.delete() when old and new storage paths are identical (UUID-based replacement) to avoid deleting the freshly written file that OverwriteStorage already placed at that path. - MetadataFileFieldSerializer: overrides to_representation only (inherits DRF FileField for writes) to emit /documentos/<uuid>/ for API responses instead of the semantic alias .url() returns. SaplSerializerMixin wires it in via build_standard_field while preserving all normal field kwargs. - nginx sapl.conf: adds `internal` and `etag on` to /media/ so clients can no longer fetch files directly; only Django's X-Accel-Redirect reaches the location. - settings.py: adds ConditionalGetMiddleware after CommonMiddleware to set ETag and Last-Modified on Django responses and short-circuit with 304. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>file-metafields
4 changed files with 97 additions and 8 deletions
Loading…
Reference in new issue