Content-Disposition fixes + hardening
This commit is contained in:
parent
b2360d5c9e
commit
4833eac81b
|
@ -22,8 +22,14 @@ function MyDropzone() {
|
|||
const onDrop = useCallback(
|
||||
acceptedFiles => {
|
||||
setLoading(true)
|
||||
const file = R.head(acceptedFiles)
|
||||
const url = API_ENDPOINT + "/skyfile"
|
||||
const file = acceptedFiles[0]
|
||||
if (!file) {
|
||||
setError("An unexpected error occured. Check console for details.")
|
||||
setLoading(false)
|
||||
return
|
||||
}
|
||||
|
||||
const url = `${API_ENDPOINT}/skyfile?filename=${file.name}`
|
||||
const fd = new FormData()
|
||||
fd.append("file", file)
|
||||
|
||||
|
|
|
@ -182,8 +182,11 @@ export class Server {
|
|||
|
||||
private async handleSkyfilePOST(req: Request, res: Response): Promise<Response> {
|
||||
const file = selectFile(req) as UploadedFile
|
||||
const uid = shortid.generate()
|
||||
if (!file) {
|
||||
res.status(400).send({ error: "Missing file" })
|
||||
}
|
||||
|
||||
const uid = shortid.generate()
|
||||
this.logger.info(`POST skyfile w/name ${file.name} and uid ${uid}`)
|
||||
|
||||
try {
|
||||
|
@ -192,7 +195,7 @@ export class Server {
|
|||
file.data,
|
||||
{
|
||||
maxContentLength: MAX_UPLOAD_FILESIZE,
|
||||
params: { name: file.name }
|
||||
params: { filename: file.name }
|
||||
}
|
||||
)
|
||||
return res.send(data)
|
||||
|
|
Reference in New Issue