Updating a file in java
Updating a file in java - Adult Chat Rooms
Using a storage service like AWS S3 to store file uploads provides an order of magnitude scalability, reliability, and speed gain than just storing files on a local filesystem.
Before you read this article check out Using AWS S3 to Store Static Assets and File Uploads which shows you how to establish the necessary S3 credentials/keys and provides a more in-depth discussion of the benefits of such an approach.Play 2 has a way to create plugins which can be automatically started when the server starts.There isn’t an official S3 Plugin for Play 2 yet but you can create your own by creating a file named app/plugins/S3with the following contents: These values work for locally development but for running on Heroku you can use the Heroku Postgres Add-on which is automatically provisioned for new Play apps.To add the Postgre SQL JDBC driver to your project, add the following dependency to your project/Build.scala file: This will override the database configuration (to use Postgre SQL) when the application runs on Heroku.Now that you have a model that holds the file metadata and uploads the file to S3, lets create a controller that will handle rendering an upload web page and handle the actual file uploads.Create (or update) a file named app/controllers/containing: with it, saves it, then redirects back to the index page.
Now let’s create a simple index page that will contain a form that allows the user to upload a file and also lists the uploads.
Create (or update) a file named app/views/index.containing: method) and a list of the files.
If you are new to Play 2 on Heroku then you will want to read the Play 2 documentation on Deploying to Heroku.
S3 provides a RESTful API for interacting with the service.
There is a Java library that wraps that API, making it easy to interact with from Java code.
In a Play 2 project you can add the After updating the dependencies in a Play 2 project you will need to restart the Play 2 server and regenerate any IDE config files (Eclipse & Intelli J).