Image upload to filesystem -> Bad request

My version of HedgeDoc is: 1.9.2

What I expected to happen:

Upload images to filesystem

What actually happened:

No image is uploaded. Error 400 bad request

I already tried:

  • check the persistence of uploadsPath
  • set uploadsPath absolute
  • change permissions of upload directory 777
  • try with and without reverse proxy
  • double checked the “domain” is set in the config

This is the resulting logentry:

2022-01-07T09:18:34.015Z error: 	Image upload error: Upload didn't contain file)
2022-01-07T09:18:34.044Z info: 	XXX.XXX.XXX.XX - - [07/Jan/2022:09:18:34 +0000] "POST /uploadimage HTTP/1.1" 400 - "http://XXXXXXX:3001/C_QRYDdgSD-Y584YwZKJIA" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:95.0) Gecko/20100101 Firefox/95.0"

With former versions of hedgedoc uploading had not been a problem.

Thanks in Advance
Adrian

Are you using Firefox on a Mac? I’m curious if the result is the same on other browsers or older versions of the browser.

Was the action a file drag-and-drop operation or was it a copy-paste operation?

Does this discussion help at all? I had similar trouble recently because I had a mounted a host volume for the uploads but had not set the ownership to UID 10000. It was failing somehow even though the chmod permissions should have allowed any user to write to the directory. Setting the uid to 10000 solved it in my case, but I do not know if I was receiving the same error message you are. It’s worth a try though.

Hi @manning-ncsa,

thanks for joining in. I tried different browsers (Firefox, Chrome and Safari). UIDs are consistent. I uploaded using the button/dialogue and ‘drag and drop’. All with the same result.

I deployed HedgeDoc 1.9.2 locally using Docker Compose as detailed below. I did not encounter any issues with photo uploads using the drag and drop or using the upload button. The test environment is Ubuntu 20.04.3 and Firefox 95.0.1 (64-bit).

Screenshot from 2022-01-07 09-57-55

Directory contents:

$ ls -lan
total 20
drwxrwxr-x 3 1000 1000 4096 Jan  7 09:45 .
drwxrwxr-x 4 1000 1000 4096 Jan  7 08:23 ..
-rw-r--r-- 1 1000 1000  448 Jan  7 09:55 docker-compose.yaml
-rw-rw-r-- 1 1000 1000 1189 Jan  7 09:48 .env
drwxrwxr-x 4 1000 1000 4096 Jan  7 09:45 volumes

$ sudo ls -lan volumes/*
volumes/db:
total 128
drwx------ 19   70 1000  4096 Jan  7 09:55 .
drwxrwxr-x  4 1000 1000  4096 Jan  7 09:45 ..
drwx------  6   70   70  4096 Jan  7 09:45 base
drwx------  2   70   70  4096 Jan  7 09:56 global
...
-rw-------  1   70   70    94 Jan  7 09:55 postmaster.pid

volumes/uploads:
total 3716
drwxrwxr-x 2 10000  1000    4096 Jan  7 09:57 .
drwxrwxr-x 4  1000  1000    4096 Jan  7 09:45 ..
-rw-r--r-- 1 10000 65534 3793675 Jan  7 09:57 ba99f11e67a3ba1faee674f00.jpg

docker-compose.yaml:

version: '3'

services:
  db:
    image: postgres:11.6-alpine
    container_name: hedgedoc-db
    env_file: .env
    volumes:
      - ./volumes/db:/var/lib/postgresql/data
    restart: unless-stopped
  app:
    image: quay.io/hedgedoc/hedgedoc:1.9.2
    container_name: hedgedoc-app
    env_file: .env
    depends_on:
      - db
    volumes:
      - ./volumes/uploads:/hedgedoc/public/uploads
    ports:
    - 3000:3000
    restart: unless-stopped

.env:

POSTGRES_DB=hedgedoc
POSTGRES_USER=hedgedoc
POSTGRES_PASSWORD=***********
CMD_DB_DIALECT=postgres
CMD_DB_HOST=db
CMD_DB_DATABASE=hedgedoc
CMD_DB_USERNAME=hedgedoc
CMD_DB_PASSWORD=***********
CMD_DOMAIN=localhost
CMD_URL_ADDPORT=true
CMD_PROTOCOL_USESSL=false
CMD_ALLOW_ANONYMOUS_EDITS=true
CMD_ALLOW_ANONYMOUS=true
1 Like

I did a clean reinstall. Everything works as expected again.

I’m glad you got things working, but my curiosity is piqued. This error occurs at this line, indicating that somehow the file information in the HTML form data was not sent properly in the HTTP request, which seems like a browser-side problem. Unfortunately I do not have experience debugging Hedgedoc so I’m just trying to make educated guesses.