I want to deploy an app in Heroku to try their new Play! Framework support. For what I've read in the site (I gotta confess I did not try it yet) they don't provide any file system. This means that (probably) Blob fields used in Play to store files won't work properly.
Could somebody:
- Confirm if you can use the Play Blob in Heroku?
- Provide the "best" alternative to store files in Heroku? Is better to store them in the database (they use PostgreSQL) or somewhere else?
I put an example of how to do this with Amazon S3 on github:
https://github.com/jamesward/plays3upload
Basically you just need to send the file to S3 and save the key in the entity:
AWSCredentials awsCredentials = new BasicAWSCredentials(System.getenv("AWS_ACCESS_KEY"), System.getenv("AWS_SECRET_KEY"));
AmazonS3 s3Client = new AmazonS3Client(awsCredentials);
s3Client.createBucket(BUCKET_NAME);
String s3Key = UUID.randomUUID().toString();
s3Client.putObject(BUCKET_NAME, s3Key, attachment);
Document doc = new Document(comment, s3Key, attachment.getName());
doc.save();
listUploads();