使用java发布pdf文件上传到谷歌文档?

时间:2012-06-14 12:35:08

标签: java google-drive-api google-docs-api

我正在尝试将pdf文件上传到Google文档/云端硬盘, 为此,我使用以下代码......

int MAX_CONCURRENT_UPLOADS = 10;
int PROGRESS_UPDATE_INTERVAL = 1000;
int DEFAULT_CHUNK_SIZE = 10485760;

ExecutorService executor = Executors.newFixedThreadPool(MAX_CONCURRENT_UPLOADS);
File file = new File(filePath);
String mimeType=DocumentListEntry.MediaType.fromFileName(file.getName()).getMimeType();
String contentType=DocumentListEntry.MediaType.fromFileName(file.getName()).getMimeType();
MediaFileSource mediaFile = new MediaFileSource(file, contentType);
URL createUploadUrl = new URL("https://drive.google.com/feeds/upload/create-session/default/private/full");
FileUploadProgressListener listener = new FileUploadProgressListener();
ResumableGDataFileUploader uploader=new ResumableGDataFileUploader(createUploadUrl,mediaFile,service, DEFAULT_CHUNK_SIZE, executor, listener, PROGRESS_UPDATE_INTERVAL);

但是FileUploadProgressListener显示错误,它是google api还是类??

请帮助上传pdf文件错误....

提前致谢