views.py

About this file

This file handles Upload endpoints for NYC OpenRecords with a function to create a new upload handling chunked files through the Content-Range header, a function to remove an uploaded file and another function to check the status of the file upload.

Code Check Report


No problems to report
                        

Documentation drawn from source code


...module:: upload.views.

:synopsis: Handles Upload endpoints for NYC OpenRecords


post(request_id):

Create a new upload.

Handles chunked files through the Content-Range header.
For filesize validation and more upload logic, see:
/static/js/upload/fileupload.js

Optional request body parameters:
- update (bool)
save the uploaded file to the 'updated' directory
(this indicates the file is meant to replace
a previously uploaded file)
- response_id (int)
the id of a response associated with the file
this upload is replacing
- REQUIRED if 'update' is 'true
- ignored if 'update' is 'false

:returns: {
name": file name,
size": file size
}

delete(r_id_type, r_id, filecode):

Removes an uploaded file.

:param r_id_type: "response" or "request
:param r_id: the Response or Request identifier
:param filecode: the encoded name of the uploaded file
(base64 without padding)

Optional request body parameters:
- quarantined_only (bool)
only delete the file if it is quarantined
(beware: takes precedence over 'updated_only')
- updated_only (bool)
only delete the file if it is in the 'updated' directory

:returns:
On success:
{ "deleted": filename }
On failure:
{ "error": error message }

status():

Check the status of an upload.

Request Parameters:
- request_id
- filename
- for_update (bool, optional)

:returns: {
status": upload status
}

Source code