Examples of DbFile


Examples of com.jeecms.core.entity.DbFile

@Repository
public class DbFileDaoImpl extends HibernateBaseDao<DbFile, String> implements
    DbFileDao {
  public DbFile findById(String id) {
    DbFile entity = get(id);
    return entity;
  }
View Full Code Here

Examples of com.jeecms.core.entity.DbFile

    getSession().save(bean);
    return bean;
  }

  public DbFile deleteById(String id) {
    DbFile entity = super.get(id);
    if (entity != null) {
      getSession().delete(entity);
    }
    return entity;
  }
View Full Code Here

Examples of com.jeecms.core.entity.DbFile

    String name = request.getParameter(PARAM_NAME);
    if (StringUtils.isBlank(name)) {
      response.sendError(HttpServletResponse.SC_NOT_FOUND);
      return;
    }
    DbFile file = dbFileMng.findById(name);
    if (file == null) {
      response.sendError(HttpServletResponse.SC_NOT_FOUND);
      return;
    }
    String mimeType = getServletContext().getMimeType(name);
    if (mimeType != null) {
      response.setContentType(mimeType);
    }
    String filename = file.getId();
    int index = filename.lastIndexOf("/");
    if (index != -1) {
      filename = filename.substring(index + 1);
    }
    response.addHeader("Content-disposition", "filename=" + filename);
    response.setContentLength(file.getLength());
    ServletOutputStream out = response.getOutputStream();
    out.write(file.getContent());
    out.flush();
    out.close();
  }
View Full Code Here

Examples of com.jeecms.core.entity.DbFile

@Service
@Transactional
public class DbFileMngImpl implements DbFileMng {
  @Transactional(readOnly = true)
  public DbFile findById(String id) {
    DbFile entity = dao.findById(id);
    return entity;
  }
View Full Code Here

Examples of com.jeecms.core.entity.DbFile

  }

  public String storeByExt(String path, String ext, InputStream in)
      throws IOException {
    String filename;
    DbFile file;
    // 判断文件是否存在
    do {
      filename = UploadUtils.generateFilename(path, ext);
      file = findById(filename);
    } while (file != null);
View Full Code Here

Examples of com.jeecms.core.entity.DbFile

    return filename;
  }

  public String storeByFilename(String filename, InputStream in)
      throws IOException {
    DbFile file = findById(filename);
    if (file != null) {
      update(file, in);
    } else {
      save(filename, in);
    }
View Full Code Here

Examples of com.jeecms.core.entity.DbFile

  public File retrieve(String name) throws IOException {
    // 此方法依赖于文件名是唯一的,否则有可能出现问题。
    String path = System.getProperty("java.io.tmpdir");
    File file = new File(path, name);
    file = UploadUtils.getUniqueFile(file);
    DbFile df = findById(name);
    FileUtils.writeByteArrayToFile(file, df.getContent());
    return file;
  }
View Full Code Here

Examples of com.jeecms.core.entity.DbFile

    return file;
  }

  private DbFile save(String filename, InputStream in) throws IOException {
    byte[] content = IOUtils.toByteArray(in);
    DbFile file = new DbFile(filename, content.length, System
        .currentTimeMillis(), content);
    dao.save(file);
    in.close();
    return file;
  }
View Full Code Here

Examples of com.jeecms.core.entity.DbFile

    in.close();
    return file;
  }

  public DbFile deleteById(String id) {
    DbFile bean = dao.deleteById(id);
    return bean;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.