當前位置: 首頁>>代碼示例>>Java>>正文


Java File.setMimeType方法代碼示例

本文整理匯總了Java中com.google.api.services.drive.model.File.setMimeType方法的典型用法代碼示例。如果您正苦於以下問題:Java File.setMimeType方法的具體用法?Java File.setMimeType怎麽用?Java File.setMimeType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.api.services.drive.model.File的用法示例。


在下文中一共展示了File.setMimeType方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createFolder

import com.google.api.services.drive.model.File; //導入方法依賴的package包/類
@Override
public String createFolder(String parentPath, String newDirName) throws Exception {
	File body = new File();
	body.setTitle(newDirName);
	body.setMimeType(FOLDER_MIME_TYPE);
	
	GDrivePath parentGdrivePath = new GDrivePath(parentPath);
	
	body.setParents(
			Arrays.asList(new ParentReference().setId(parentGdrivePath.getGDriveId())));
	try
	{
		File file = getDriveService(parentGdrivePath.getAccount()).files().insert(body).execute();
		
		logDebug("created folder "+newDirName+" in "+parentPath+". id: "+file.getId());

		return new GDrivePath(parentPath, file).getFullPath();
	}
	catch (Exception e)
	{
		throw convertException(e);
	}

}
 
開發者ID:PhilippC,項目名稱:keepass2android,代碼行數:25,代碼來源:GoogleDriveFileStorage.java

示例2: simpleUpload

import com.google.api.services.drive.model.File; //導入方法依賴的package包/類
public void simpleUpload(java.io.File filePath,String name,String mime) throws IOException{
    driveService = getDriveService();
    File fileMetadata = new File();
    fileMetadata.setName(name);
    fileMetadata.setMimeType(mime);

    FileContent mediaContent = new FileContent(mime, filePath);
    File file = driveService.files().create(fileMetadata, mediaContent)
    .setFields("id")
    .execute();
    System.out.println("File ID: " + file.getId());
}
 
開發者ID:Obsidiam,項目名稱:joanne,代碼行數:13,代碼來源:UploadFiles.java

示例3: creatFolder

import com.google.api.services.drive.model.File; //導入方法依賴的package包/類
public void creatFolder() throws IOException {
	LOGGER.info("creating new folder");
	 File fileMetadata = new File();
	 fileMetadata.setName("cemu_savegames");
	 fileMetadata.setMimeType("application/vnd.google-apps.folder");

	 File file = service.files().create(fileMetadata).setFields("id").execute();
	 LOGGER.info("Folder ID: " + file.getId());
	 folderID = file.getId();
}
 
開發者ID:Seil0,項目名稱:cemu_UI,代碼行數:11,代碼來源:GoogleDriveController.java

示例4: move

import com.google.api.services.drive.model.File; //導入方法依賴的package包/類
@Override
public Path move(final Path file, final Path renamed, final TransferStatus status, final Delete.Callback callback, final ConnectionCallback connectionCallback) throws BackgroundException {
    try {
        if(status.isExists()) {
            delete.delete(Collections.singletonList(renamed), connectionCallback, callback);
        }
        final String fileid = new DriveFileidProvider(session).getFileid(file, new DisabledListProgressListener());
        if(!StringUtils.equals(file.getName(), renamed.getName())) {
            // Rename title
            final File properties = new File();
            properties.setName(renamed.getName());
            properties.setMimeType(status.getMime());
            session.getClient().files().update(fileid, properties).
                setSupportsTeamDrives(PreferencesFactory.get().getBoolean("googledrive.teamdrive.enable")).execute();
        }
        // Retrieve the existing parents to remove
        final StringBuilder previousParents = new StringBuilder();
        final File reference = session.getClient().files().get(fileid)
            .setFields("parents")
            .setSupportsTeamDrives(PreferencesFactory.get().getBoolean("googledrive.teamdrive.enable"))
            .execute();
        for(String parent : reference.getParents()) {
            previousParents.append(parent);
            previousParents.append(',');
        }
        // Move the file to the new folder
        session.getClient().files().update(fileid, null)
            .setAddParents(new DriveFileidProvider(session).getFileid(renamed.getParent(), new DisabledListProgressListener()))
            .setRemoveParents(previousParents.toString())
            .setFields("id, parents")
            .setSupportsTeamDrives(PreferencesFactory.get().getBoolean("googledrive.teamdrive.enable"))
            .execute();
        return new Path(renamed.getParent(), renamed.getName(), renamed.getType(),
            new PathAttributes(renamed.attributes()).withVersionId(fileid));
    }
    catch(IOException e) {
        throw new DriveExceptionMappingService().map("Cannot rename {0}", e, file);
    }
}
 
開發者ID:iterate-ch,項目名稱:cyberduck,代碼行數:40,代碼來源:DriveMoveFeature.java

示例5: getPhotosFolder

import com.google.api.services.drive.model.File; //導入方法依賴的package包/類
private File getPhotosFolder() {
    try {

        File folder = getFile("photos");

        if (folder == null) {

            File photos = new File();
            photos.setTitle("photos");
            photos.setAppDataContents(true);
            photos.setMimeType(FOLDER_MIME);
            photos.setParents(Arrays.asList(new ParentReference().setId(getAppFolder().getId())));

            photos = service.files().insert(photos).execute();

            return photos;

        } else {
            return folder;
        }

    } catch (Exception e) {
        e.printStackTrace();
        if (!BuildConfig.DEBUG) Crashlytics.logException(e);
    }

    return null;
}
 
開發者ID:timothymiko,項目名稱:narrate-android,代碼行數:29,代碼來源:DriveSyncService.java

示例6: insertFile

import com.google.api.services.drive.model.File; //導入方法依賴的package包/類
/**
 * Insert new file.
 *
 * @param title Title of the file to insert, including the extension.
 * @param description Description of the file to insert.
 * @param parentId Optional parent folder's ID.
 * @param mimeType MIME type of the file to insert.
 * @param file The file to insert.
 * @return Inserted file metadata if successful, {@code null} otherwise.
 */
private File insertFile(String title, String description, String parentId, String mimeType, java.io.File file)
        throws IOException {
    File body = new File();
    body.setTitle(title);
    body.setDescription(description);
    body.setMimeType(mimeType);

    if (parentId != null && parentId.length() > 0) {
        body.setParents(Collections.singletonList(new ParentReference().setId(parentId)));
    }

    FileContent mediaContent = new FileContent(mimeType, file);
    return drive.files().insert(body, mediaContent).execute();
}
 
開發者ID:nassendelft,項目名稱:jenkins-plugin-google-driver-uploader,代碼行數:25,代碼來源:GoogleDriveManager.java

示例7: uploadTestFolder

import com.google.api.services.drive.model.File; //導入方法依賴的package包/類
protected File uploadTestFolder() {
    File fileMetadata = new File();
    fileMetadata.setTitle("testfolder");
    fileMetadata.setMimeType("application/vnd.google-apps.folder");

    File result = requestBody("google-drive://drive-files/insert?inBody=content", fileMetadata);
    return result;
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:9,代碼來源:AbstractGoogleDriveTestSupport.java


注:本文中的com.google.api.services.drive.model.File.setMimeType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。