How to save a photograph to MySQL from GWTUpload SingleUploader?

懵懂的女人 提交于 2019-12-25 01:45:31

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!