diff options
| author | Jan Friedli | 2020-07-13 08:14:47 +0200 |
|---|---|---|
| committer | Jan Friedli | 2020-07-13 08:14:47 +0200 |
| commit | 2c1bc2f05af93e13d331e0f6a5c1b617717a50e3 (patch) | |
| tree | a6c2a853ccbcf6f353791d56b63911a6bbedfd12 | |
| parent | 6aa9fa7029ae15d0a18657fb9deccc3313aed9e1 (diff) | |
documented download endpoint
| -rw-r--r-- | matweb/oas/download.yml | 33 | ||||
| -rw-r--r-- | matweb/rest_api.py | 1 |
2 files changed, 34 insertions, 0 deletions
diff --git a/matweb/oas/download.yml b/matweb/oas/download.yml new file mode 100644 index 0000000..4c101a4 --- /dev/null +++ b/matweb/oas/download.yml | |||
| @@ -0,0 +1,33 @@ | |||
| 1 | --- | ||
| 2 | tags: | ||
| 3 | - "File Download" | ||
| 4 | summary: 'Download a single cleaned file or zip archive containing multiple files' | ||
| 5 | consumes: | ||
| 6 | - "application/json" | ||
| 7 | produces: | ||
| 8 | - "*/*" | ||
| 9 | parameters: | ||
| 10 | - name: "key" | ||
| 11 | in: "path" | ||
| 12 | description: "A key generated for that resource" | ||
| 13 | required: true | ||
| 14 | type: "string" | ||
| 15 | - name: "secret" | ||
| 16 | in: "path" | ||
| 17 | description: "A secret generated for that resource" | ||
| 18 | required: true | ||
| 19 | type: "string" | ||
| 20 | - name: "filename" | ||
| 21 | in: "path" | ||
| 22 | description: "the filename of the cleaned file" | ||
| 23 | required: true | ||
| 24 | type: "string" | ||
| 25 | |||
| 26 | |||
| 27 | responses: | ||
| 28 | 200: | ||
| 29 | description: "An object containing all info about the cleaned file" | ||
| 30 | schema: | ||
| 31 | $ref: '#/definitions/UploadResponse' | ||
| 32 | 404: | ||
| 33 | description: "The filename, key or secret are wrong" \ No newline at end of file | ||
diff --git a/matweb/rest_api.py b/matweb/rest_api.py index 4aeaa62..20ec155 100644 --- a/matweb/rest_api.py +++ b/matweb/rest_api.py | |||
| @@ -72,6 +72,7 @@ class APIDownload(Resource): | |||
| 72 | def __init__(self, **kwargs): | 72 | def __init__(self, **kwargs): |
| 73 | self.upload_folder = kwargs['upload_folder'] | 73 | self.upload_folder = kwargs['upload_folder'] |
| 74 | 74 | ||
| 75 | @swag_from('./oas/download.yml') | ||
| 75 | def get(self, key: str, secret: str, filename: str): | 76 | def get(self, key: str, secret: str, filename: str): |
| 76 | complete_path, filepath = utils.is_valid_api_download_file(filename, key, secret, self.upload_folder) | 77 | complete_path, filepath = utils.is_valid_api_download_file(filename, key, secret, self.upload_folder) |
| 77 | # Make sure the file is NOT deleted on HEAD requests | 78 | # Make sure the file is NOT deleted on HEAD requests |
