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