简体   繁体   English

如何从GWTUpload SingleUploader将照片保存到MySQL?

[英]How to save a photograph to MySQL from GWTUpload SingleUploader?

I am using Eclipse Juno and GWTUpload SingleUploader to select and display a photograph. 我正在使用Eclipse Juno和GWTUpload SingleUploader选择并显示照片。 There are a few minor issues however the next major thing to do is save the input to MySQL. 有一些小问题,但是接下来要做的主要事情是将输入保存到MySQL。 So how do I now pass the photograph to MySQL. 那么,现在如何将照片传递给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). 我打算做的是将照片存储在temp文件夹中,在写入数据库时​​从temp文件夹中将其拾取,然后从temp文件夹中删除照片(清理)。 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. 我在服务器端有以下代码(从https://code.google.com/p/gwtupload/wiki/GwtUpload_GettingStarted的第7步复制),但是我有两个问题无法解决。

/**
   * 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);" 第一个问题在“字符串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. 在出现错误“ UConsts无法解析为变量”的地方,我的选择是:创建常量,创建类,创建接口,创建局部变量,创建字段,创建枚举,创建参数,修复项目设置。

The second issue is at line "renderXmlResponse(request, response, XML_ERROR_ITEM_NOT_FOUND);" 第二个问题在“ renderXmlResponse(请求,响应,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. 在出现错误“ XML_ERROR_ITEM_NOT_FOUND无法解析为变量”的地方,我的选择是:创建常量,创建局部变量,创建字段,创建参数以及一些更改选项,我怀疑这些答案是正确的,因为这是作者证明的代码。

Your help is greatly appreciated. 非常感谢您的帮助。

Regards, Glyn 问候,格林

Is it your project requirement to save the image to DB? 将映像保存到DB是您的项目要求吗?

Another approach might be saving the image file to the local file system and storing the full path of the file in DB. 另一种方法可能是将映像文件保存到本地文件系统,然后将文件的完整路径存储在DB中。 This will save from heavy database. 这将从繁重的数据库中保存。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM