Is there a recommendation on how to handle image f...
# orm-help
j
Is there a recommendation on how to handle image file, or regular file, uploads? Keep the file as is, or base64 encode to the database?
1
r
hi @Joe Generally you want to save the file to some disk and store the location in the database..
so upload to S3 and in the database have :
Copy code
id: xxxx,
bucketName: "xyz",
key: "some/path/andFilename.jpg",
substitute S3 for wherever you want to save the file..
Base64 makes the file size about 30% larger, cannot easily be cached, makes your db take more disk space (usually more expensive than storage), makes your db backups bigger increases the payload size when you return data from your backend to your frontend..
👍 1
all those are pretty good reasons on not go "Base64 in the db"..
👍 1
💯 1
(and that would be for any file..)
j
thanks! the file server needs to be behind the same firewall prisma is (using apollo) so i’ll just use prisma for the object and location storage workflow you have above, thanks for the advice!!
👍 1