如何从GWTUpload SingleUploader将照片保存到MySQL? [英] How to save a photograph to MySQL from GWTUpload SingleUploader?

查看:268
本文介绍了如何从GWTUpload SingleUploader将照片保存到MySQL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Eclipse Juno和GWTUpload SingleUploader来选择和显示照片。有一些小问题,但下一个主要的工作是将输入保存到MySQL。那么如何将照片传递给MySQL呢?我打算做的是将照片存储在临时文件夹中,在写入数据库时​​从临时文件夹中取出,然后从临时文件夹中删除照片(清理)。我有以下代码(从 https://code.google.com/的步骤7复制) p / gwtupload / wiki / GwtUpload_GettingStarted )在服务器端,但我有两个问题,我无法解决。

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);
   }
  }

第一个问题是String fieldName = request .getParameter(UConsts.PARAM_SHOW);我收到错误UConsts无法解析为变量我的选项是:创建常量,创建类,创建接口,创建局部变量,创建字段,创建枚举,创建参数,修复项目设置。

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.

第二个问题是renderXmlResponse(request,response,XML_ERROR_ITEM_NOT_FOUND);在那里我得到错误XML_ERROR_ITEM_NOT_FOUND无法解析为变量我的选项是:创建常量,创建局部变量,创建字段,创建参数和一些更改选项,我怀疑是答案,因为这是作者的证明代码。

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.

非常感谢您的帮助。

问候,Glyn

推荐答案

您的项目要求将图像保存到DB吗?

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.

这篇关于如何从GWTUpload SingleUploader将照片保存到MySQL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆