コード例 #1
0
  public static String saveProduct(FileStorage storage, File productFile, String id, int version)
      throws IOException {
    FileContent content = makeFileContentWithFile(productFile);
    if (content == null) return null;

    String fid =
        FilenameUtils2.changeFilenameWithoutExt(content.filename, makeProductFilename(id, version));
    return storage.write(fid, content);
  }
コード例 #2
0
  public static String saveImageWithFileItem(
      FileStorage storage, String imageField, String id, FileItem fi) throws IOException {
    if (fi == null) return null;

    String imageType = StringUtils.removeEnd(imageField, "_image");
    FileContent content = makeFileContentWithFileItem(fi);
    if (content == null) return null;

    String fid =
        FilenameUtils2.changeFilenameWithoutExt(
            content.filename, makeProductImageFilename(id, imageType));
    return storage.write(fid, content);
  }