gchq / gchq/CyberChef-server

Return a file when outputType is file

Open
#23 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
179
Forks
66
PR merge metrics
No merged PRs in 30d

Description

`outputType` is an optional parameter that can be specified when POSTing to `/bake`. When `outputType` is set as `"file"` or `7`, the application should return a file.

**Describe the solution you'd like**
- if `outputType=file` in the request, the application should:
- set `Content-Disposition` to `attachment` in the response
- only return the dish value as the payload, so that if you pipe the response to a file, it should only contain the value.

- this behaviour should apply to multipart and body POSTs

For reference (with multipart at least), the response when `outputType=7` is:
```
type: "FILE",
value: {
data: {
data: [
84,
104,
101,
32,
99
],
type: "Buffer"
},
lastModified: 1593784118511,
name: "unknown",
type: "application/unknown",
}
```

---

test for outputType = file is:
- expect a file of binary data out (e.g. png). Write it to x.png and open it. it should be valid.

Contributor guide

Open the contributing guide

Research direction

Start at the POST /bake handling for body and multipart requests, then trace how outputType values "file" and 7 are converted into responses. Verify the response sets Content-Disposition to attachment and contains only the dish value as binary data. Test with a binary input such as a PNG, write the response to x.png, and confirm it opens as a valid file.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api, backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.