0

I already have PlayFramework app runing , but I am in process of migrating it to Heroku. Because on Heroku I can not use local filesystem like I did in my app. I am forced to use Amazon S3 ,but I do not know how to rewrite creating of thumbnails. For that I am using :

https://github.com/coobird/thumbnailator

Thumbnails.of(picture.getFile()).size(300,300).toFile(new File("public/images/data", thumb));

The problem is that I can not do this at heroku,because file wont be saved.

How do I create thumbnails then? If I do not want to use another service which will generate thumbnails for me and save them to s3 somehow...

Honestly if I would know how many different services would I need for simple page with java then I would stay at php forever...

JDoe
  • 1

1 Answers1

1

In Heroku (as in many PaaS) there's no persistent filesystem. However, you do have access to temp directory. So you could save it into a temp file

File temp = File.createTempFile("prefix", "suffix").getAbsolutePath;
Thumbnails.of(picture.getFile()).size(300,300).toFile(temp, thumb));

Then take that file and upload it to S3. If you strictly insist on not using S3 for storing binary files, then you could base64 the file content and save it into the DB. (see some pros/cons for such approach here)

Community
  • 1
  • 1
LiorH
  • 18,524
  • 17
  • 70
  • 98