|
Replies:
1
-
Pages:
1
-
Last Post:
Jan 15, 2010 12:02 AM
by: glen.smith
|
Threads:
[
Previous
|
Next
]
|
|
Posts:
15
From:
Australia
Registered:
3/4/08
|
|
|
|
Page 146: MultipartHttpServletRequest or MultipartFile?
Posted:
Jan 14, 2010 10:28 PM
|
|
The code for Uploading to the filesystem indicates that the file is saved as a gif. Wonderful, thinks I, upload it as a jpg or png or whatever, and save it to what one wants to. This looks too good to be true. So I checked the transferTo(File file) method in the Spring doc. MultipartHttpServletRequest is an interface, not a class as said, and it does not have a transferTo(File file) method. The interface MultipartFile has one and it does what the code indicates, save the magic format conversion.
The Errata is only up to page 77. The code for rawUpload won't work as it is. Can it be fixed so it will work?
Thanks.
PS Grails really rocks. I've been with EJB 2.1, EJB3, Seam and Ruby on Rails. If it wasn't for Grails I would have been with Ruby. The book is nicely written. However, it is too divorced from the Example application code. I bought Grails - A Quick Start Guide as well. This really does what it says.
|
|
Posts:
142
From:
Canberra, Australia
Registered:
7/24/08
|
|
|
|
Re: Page 146: MultipartHttpServletRequest or MultipartFile?
Posted:
Jan 15, 2010 12:02 AM
in response to:
chrismalan
|
|
Thanks Chris.
A more current source of errata is the wiki for the source code. I've added a chapter 5 errata page to catch this one. We have existing reported errata for chapters 1,3 & 7.
http://wiki.github.com/pledbrook/graina/chapter-5-errata
In your specific case... thanks for reporting this. I'm guessing your connecting the picture from section 5.5.1 with the code from the example if 5.5.2 (since the image in on the same page as 5.5.2). The sample code always uploads the image to byte[], so its "filename/type" is never stored on disk and the browser resolves the image format when we send the byte[] back (eg in 5.5.3).
5.5.2 should really say that you'll need to determine the type yourself if you want to store the image bytes in particular formats on disk. We'll make a comment about this in the next edition.
As for the MultipartHttpServletRequest description, that is definitely an error and needs to be fixed. Here's what I wrote about that in the errata page...
------ The text also mentions that MultipartHttpServletRequest is a class, whilst technically it’s an interface. It’s the incoming request object that implements this interface in some concrete type. Calling getFile() on an implementation of MultipartHttpServletRequest hands you back an implementation of MultipartFile which you can then call transferTo() method on. For this reason, the variable would be better named mpf rather than mhsr (which is inaccurate). ------
Thanks again for report it,
Glen.
|
|
|
Legend
|
|
Gold: 300
+
pts
|
|
Silver: 100
- 299
pts
|
|
Bronze: 25
- 99
pts
|
|
Manning Author
|
|
Manning Staff
|
|