Manually added files in uploads folder are giving 404

docker

(Pratyush Mittal) #1

I am trying to migrate attachements from our old forum to Discourse. However, manually uploaded files in /var/discourse/shared/standalone/uploads/ are not showing.

I have tried:

cd /var/discourse/shared/standalone/uploads/
mkdir migrated
touch migrated/hello.txt

Now opening discourse.website.com/uploads/migrated/hello.txt gives 404. It was working on the dev-server though.


(Jens Maier) #2

You cannot upload arbitrary data to Discourse’s uploads directory. This works on the dev server because the dev HTTP server, typically Thin or WEBrick, will happily serve anything in /public to the client, but things are different in development mode where all requests will go through Discourse, and if Discourse’s database does not know about the file, it will emit a 404 error without consulting the filesystem.

If you are migrating an old forum, have a look at the importer scripts provided with Discourse and how these scripts create uploads in Discourse’s database. Beware, tho, that if there exists no post that links to an upload, the upload will be considered an orphan and will eventually be automatically deleted. :slight_smile:


(Dan Dascalescu) #3

I’ve migrated from MyBB, whose importer also doesn’t handle attachments.

The only way to bring attachments was to manually comb through posts (!) which obviously doesn’t scale.

To help with that, I wrote a post-processing script that warns you if a post contains “attach” (much like that Gmail Labs feature that reminds you that you might’ve forgotten to add attachments). It’s not perfect, obviously, because a post may just say “Check out the screenshot below”, but it’s better than nothing.

Is there a way to make the importers dump a list of posts that have attachments?


(Kane York) #4

Even better, the importer could create the Upload records :wink: