本文整理了Java中com.google.api.services.drive.model.File.<init>()
方法的一些代码示例,展示了File.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。File.<init>()
方法的具体详情如下:
包路径:com.google.api.services.drive.model.File
类名称:File
方法名:<init>
暂无
代码示例来源:origin: stackoverflow.com
final com.google.api.services.drive.model.File body = new com.google.api.services.drive.model.File();
body.setTitle("My Test File");
body.setDescription("A Test File");
代码示例来源:origin: google/data-transfer-project
private String importSingleFolder(
UUID jobId,
Drive driveInterface,
String folderName,
String folderId,
String parentId) throws IOException {
File newFolder = new File()
.setName(folderName)
.setMimeType(DriveExporter.FOLDER_MIME_TYPE);
if (!Strings.isNullOrEmpty(parentId)) {
newFolder.setParents(ImmutableList.of(parentId));
}
File resultFolder = driveInterface.files().create(newFolder).execute();
DriveFolderMapping mapping = new DriveFolderMapping(folderId, resultFolder.getId());
jobStore.update(jobId, folderId, mapping);
return resultFolder.getId();
}
代码示例来源:origin: pentaho/pentaho-kettle
protected void doCreateFolder() throws Exception {
if ( !getName().getBaseName().isEmpty() ) {
File folder = new File();
folder.setName( getName().getBaseName() );
folder.setMimeType( MIME_TYPES.FOLDER.mimeType );
folder = driveService.files().create( folder ).execute();
if ( folder != null ) {
id = folder.getId();
mimeType = MIME_TYPES.get( folder.getMimeType() );
}
}
}
代码示例来源:origin: apache/incubator-gobblin
private FileList createFileList(java.util.List<String> fileIds, String folderId) {
FileList fileList = new FileList();
java.util.List<File> list = Lists.newArrayList();
for (String fileId : fileIds) {
File f = new File();
f.setId(fileId);
f.setModifiedTime(new DateTime(System.currentTimeMillis()));
list.add(f);
}
if (folderId != null) {
File f = new File();
f.setMimeType(FOLDER_MIME_TYPE);
f.setId(folderId);
f.setModifiedTime(new DateTime(System.currentTimeMillis()));
list.add(f);
}
fileList.setFiles(list);
return fileList;
}
}
代码示例来源:origin: google/data-transfer-project
private void importSingleFile(
UUID jobId,
Drive driveInterface,
DigitalDocumentWrapper file,
String parentId)
throws IOException {
InputStreamContent content = new InputStreamContent(
null,
jobStore.getStream(jobId, file.getCachedContentId()));
DtpDigitalDocument dtpDigitalDocument = file.getDtpDigitalDocument();
File driveFile = new File().setName(dtpDigitalDocument.getName());
if (!Strings.isNullOrEmpty(parentId)) {
driveFile.setParents(ImmutableList.of(parentId));
}
if (!Strings.isNullOrEmpty(dtpDigitalDocument.getDateModified())) {
driveFile.setModifiedTime(DateTime.parseRfc3339(dtpDigitalDocument.getDateModified()));
}
if (!Strings.isNullOrEmpty(file.getOriginalEncodingFormat())
&& file.getOriginalEncodingFormat().startsWith("application/vnd.google-apps.")) {
driveFile.setMimeType(file.getOriginalEncodingFormat());
}
driveInterface.files().create(
driveFile,
content
).execute();
}
代码示例来源:origin: apache/incubator-gobblin
final File file = new File();
file.setId("testId");
file.setModifiedTime(new DateTime(System.currentTimeMillis()));
代码示例来源:origin: pentaho/pentaho-kettle
public void close() throws IOException {
File file = new File();
file.setName( getName().getBaseName() );
if ( parent != null ) {
file.setParents( Collections.singletonList( parent.getId() ) );
}
ByteArrayContent fileContent = new ByteArrayContent( "application/octet-stream", toByteArray() );
if ( count > 0 ) {
driveService.files().create( file, fileContent ).execute();
( (GoogleDriveFileSystem) getFileSystem() ).clearFileFromCache( getName() );
}
}
};
代码示例来源:origin: stackoverflow.com
com.google.api.services.drive.model.File file = new com.google.api.services.drive.model.File();
file.setTitle("test");
file.setMimeType("application/vnd.google-apps.spreadsheet");
Insert insert = this.drive.files().insert(file);
file = insert.execute();
代码示例来源:origin: stackoverflow.com
com.google.api.services.drive.model.File myFile = new com.google.api.services.drive.model.File();
myFile.setDownloadUrl("https://drive.google.com/drive/u/0/folders/<encrypted_id>");
myFile.setId("<encrypted_id>");
Drive service = getDriveService(); // Assuming you have a method to authorize and get drive
BufferedReader br = new BufferedReader(new InputStreamReader(downloadFile(service,myFile));
....
....
...
代码示例来源:origin: andresoviedo/google-drive-ftp-adapter
public File trashFile(String fileId) {
File patch = new File();
patch.setTrashed(true);
return patchFile(fileId, patch, 3);
}
代码示例来源:origin: gsuitedevs/java-samples
public String copyPresentation(String presentationId, String copyTitle) throws IOException {
Drive driveService = this.driveService;
// [START slides_copy_presentation]
File copyMetadata = new File().setName(copyTitle);
File presentationCopyFile =
driveService.files().copy(presentationId, copyMetadata).execute();
String presentationCopyId = presentationCopyFile.getId();
// [END slides_copy_presentation]
return presentationCopyId;
}
代码示例来源:origin: io.github.aktoluna/slnarch-common
public File uploadFile(java.io.File file) throws IOException {
File fileMetadata = new File();
fileMetadata.setTitle(file.getName());
FileContent mediaContent = new FileContent("*/*", file);
Drive.Files.Insert insert = drive.files().insert(fileMetadata, mediaContent);
MediaHttpUploader uploader = insert.getMediaHttpUploader();
uploader.setDirectUploadEnabled(false);
uploader.setProgressListener(new FileUploadListener());
return insert.execute();
}
代码示例来源:origin: org.talend.components/components-googledrive-runtime
private String removeResource(String resourceId, boolean useTrash) throws IOException {
if (useTrash) {
drive.files().update(resourceId, new File().setTrashed(true)).execute();
} else {
drive.files().delete(resourceId).execute();
}
return resourceId;
}
代码示例来源:origin: Talend/components
private String removeResource(String resourceId, boolean useTrash) throws IOException {
if (useTrash) {
drive.files().update(resourceId, new File().setTrashed(true)).execute();
} else {
drive.files().delete(resourceId).execute();
}
return resourceId;
}
代码示例来源:origin: com.github.robozonky/robozonky-integration-stonky
private File createRoboZonkyFolder(final Drive driveService) throws IOException {
final File fileMetadata = new File();
fileMetadata.setName(getFolderName(sessionInfo));
fileMetadata.setDescription("RoboZonky aktualizuje obsah tohoto adresáře jednou denně brzy ráno.");
fileMetadata.setMimeType(MIME_TYPE_FOLDER);
final File result = driveService.files().create(fileMetadata)
.setFields(getFields())
.execute();
LOGGER.debug("Created a new Google folder '{}'.", result.getId());
return result;
}
代码示例来源:origin: RoboZonky/robozonky
private File createRoboZonkyFolder(final Drive driveService) throws IOException {
final File fileMetadata = new File();
fileMetadata.setName(getFolderName(sessionInfo));
fileMetadata.setDescription("RoboZonky aktualizuje obsah tohoto adresáře jednou denně brzy ráno.");
fileMetadata.setMimeType(MIME_TYPE_FOLDER);
final File result = driveService.files().create(fileMetadata)
.setFields(getFields())
.execute();
LOGGER.debug("Created a new Google folder '{}'.", result.getId());
return result;
}
代码示例来源:origin: RoboZonky/robozonky
public static File getFile(final String name, final String id) {
final File result = new File();
result.setId(id);
result.setMimeType("application/vnd.google-apps.files");
result.setName(name);
result.setModifiedTime(new DateTime(System.currentTimeMillis()));
return result;
}
代码示例来源:origin: iterate-ch/cyberduck
@Override
public void setMetadata(final Path file, final Map<String, String> metadata) throws BackgroundException {
try {
final String fileid = this.fileid.getFileid(file, new DisabledListProgressListener());
final File body = new File();
body.setProperties(metadata);
session.getClient().files().update(fileid, body).setFields("properties").
setSupportsTeamDrives(PreferencesFactory.get().getBoolean("googledrive.teamdrive.enable")).execute();
}
catch(IOException e) {
throw new DriveExceptionMappingService().map("Failure to write attributes of {0}", e, file);
}
}
}
代码示例来源:origin: iterate-ch/cyberduck
@Override
public Path touch(final Path file, final TransferStatus status) throws BackgroundException {
try {
final Drive.Files.Create insert = session.getClient().files().create(new File()
.setName(file.getName())
.setMimeType(status.getMime())
.setParents(Collections.singletonList(fileid.getFileid(file.getParent(), new DisabledListProgressListener()))));
final File execute = insert.setSupportsTeamDrives(PreferencesFactory.get().getBoolean("googledrive.teamdrive.enable")).execute();
return new Path(file.getParent(), file.getName(), file.getType(),
new DriveAttributesFinderFeature(session, fileid).toAttributes(execute));
}
catch(IOException e) {
throw new DriveExceptionMappingService().map("Cannot create file {0}", e, file);
}
}
代码示例来源:origin: iterate-ch/cyberduck
@Override
public Path copy(final Path source, final Path target, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException {
try {
final File copy = session.getClient().files().copy(fileid.getFileid(source, new DisabledListProgressListener()), new File()
.setParents(Collections.singletonList(fileid.getFileid(target.getParent(), new DisabledListProgressListener())))
.setName(target.getName()))
.setSupportsTeamDrives(PreferencesFactory.get().getBoolean("googledrive.teamdrive.enable")).execute();
return new Path(target.getParent(), target.getName(), target.getType(),
new PathAttributes(target.attributes()).withVersionId(copy.getId()));
}
catch(IOException e) {
throw new DriveExceptionMappingService().map("Cannot copy {0}", e, source);
}
}
内容来源于网络,如有侵权,请联系作者删除!