Improve file download capabilities #5129
Open
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.
Any background context you want to provide?
Files with commas in their names (e.g., 12,props,eui,80.xlsx) were downloading as zero bytes from the dataset detail page. This only affected ImportFiles uploaded through the dataset upload endpoint.
For context, there are 6 'file' models that can be downloaded:
ImportFile,BuildingFile,InventoryDocument,AnalysisOutputFile,AnalysisInputFile, andResultFile. Of those,AnalysisOutputFile,AnalysisInputFile, andResultFileare named internally and are not at risk of having an invalid name.Downloading
InventoryDocuments,BuildingFiles, andImportFilesfrom the inventory detail page succeeded even if those files contained commas because Django'sFileFieldautomatically sanitizes filenames on upload.What's this PR do?
Updates the media
retrieveendpoint to serve directly through Django instead of nginxX-Accel-Redirectwhich cannot handle commas or special characters in the filename:ImportFilesTo prevent future issues, imported files are now sanitized on upload to remove problematic characters.
How should this be manually tested?
/data/<id>/).ImportFile,InventoryDocument, andBuildingFiledownloads from the inventory detail (/properties/<id>/) page. These downloads should already succeed on the develop branch.What are the relevant tickets?
#5075
Screenshots (if appropriate)