use of com.google.api.services.drive.model.File.ContentHints in project OpenRefine by OpenRefine.
the class UploadCommand method uploadOpenRefineProject.
private String uploadOpenRefineProject(Project project, String token, String name, List<Exception> exceptions) {
FileOutputStream fos = null;
try {
java.io.File filePath = java.io.File.createTempFile(name, ".tgz");
filePath.deleteOnExit();
fos = new FileOutputStream(filePath);
FileProjectManager.gzipTarToOutputStream(project, fos);
Thumbnail tn = new Thumbnail();
tn.setMimeType("image/x-icon").encodeImage(getIconImage());
ContentHints contentHints = new ContentHints();
contentHints.setThumbnail(tn);
File fileMetadata = new File();
fileMetadata.setName(name + ".tar.gz").setDescription(METADATA_DESCRIPTION).setContentHints(contentHints);
FileContent projectContent = new FileContent("application/x-gzip", filePath);
File file = GoogleAPIExtension.getDriveService(token).files().create(fileMetadata, projectContent).setFields("id").execute();
logger.info("File ID: " + file.getId());
return file.getId();
} catch (IOException e) {
logger.error(ExceptionUtils.getStackTrace(e));
exceptions.add(e);
}
return null;
}
Aggregations