问题
I am using Eclipse Juno and GWTUpload SingleUploader to select and display a photograph. There are a few minor issues however the next major thing to do is save the input to MySQL. So how do I now pass the photograph to MySQL. What I plan to do is store the photograph in a temp folder, pick it up from the temp folder when writing to the DB and then delete the photograph from the temp folder (clean up). I have the following code (copied from step 7 of https://code.google.com/p/gwtupload/wiki/GwtUpload_GettingStarted) on the server side however I have two issues in that I have been unable to resolve.
/**
* Get the content of an uploaded file.
*/
@Override
public void getUploadedFile(HttpServletRequest request, HttpServletResponse response) throws IOException {
String fieldName = request.getParameter(UConsts.PARAM_SHOW);
File f = receivedFiles.get(fieldName);
if (f != null) {
response.setContentType(receivedContentTypes.get(fieldName));
FileInputStream is = new FileInputStream(f);
copyFromInputStreamToOutputStream(is, response.getOutputStream());
} else {
renderXmlResponse(request, response, XML_ERROR_ITEM_NOT_FOUND);
}
}
The first issue is at line "String fieldName = request.getParameter(UConsts.PARAM_SHOW);" where I get the error "UConsts cannot be resolved to a variable" my options are: create constant, create class, create interface, create local variable, create field, create enum, create parameter, fix project setup.
The second issue is at line "renderXmlResponse(request, response, XML_ERROR_ITEM_NOT_FOUND);" where I get the error "XML_ERROR_ITEM_NOT_FOUND cannot be resolved to a variable" my options are: create constant, create local variable, create field, create parameter, and some change options which I doubt are the answer as this is proven code from the author.
Your help is greatly appreciated.
Regards, Glyn
回答1:
Is it your project requirement to save the image to DB?
Another approach might be saving the image file to the local file system and storing the full path of the file in DB. This will save from heavy database.
来源:https://stackoverflow.com/questions/17165873/how-to-save-a-photograph-to-mysql-from-gwtupload-singleuploader