-
Book Overview & Buying
-
Table Of Contents
Grails 1.1 Web Application Development
By :
Besides posting messages, our users also want to be able to upload files to share with other members of their team. Sounds good! But wait a minute, isn't file uploading a bit of a pain? First of all, we need to read the binary file data off the request, and then we need to figure out where to put the file. Do we store it on the file system, or in a database? Well, let's take a look.
In this chapter, we will see how easy it is to manage file uploads and downloads in a Grails application.
The first step, as usual, is to create a domain object to represent a file. We want to store the following information:
Name
The data of the file
A description of the file
The file size
Who uploaded the file
The date the file was created and last modified
Create the File domain class as follows:
package app
class File {
private static final int TEN_MEG_IN_BYTES = 1024*1024*10
byte[] data
String name
String description
int size
String extension
User user...
Change the font size
Change margin width
Change background colour