本文整理匯總了Java中com.google.api.services.drive.model.File.setParents方法的典型用法代碼示例。如果您正苦於以下問題:Java File.setParents方法的具體用法?Java File.setParents怎麽用?Java File.setParents使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.api.services.drive.model.File
的用法示例。
在下文中一共展示了File.setParents方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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);
}
}
示例2: createFilePath
import com.google.api.services.drive.model.File; //導入方法依賴的package包/類
@Override
public String createFilePath(String parentPath, String newFileName) throws Exception {
File body = new File();
body.setTitle(newFileName);
GDrivePath parentGdrivePath = new GDrivePath(parentPath);
body.setParents(
Arrays.asList(new ParentReference().setId(parentGdrivePath.getGDriveId())));
try
{
File file = getDriveService(parentGdrivePath.getAccount()).files().insert(body).execute();
return new GDrivePath(parentPath, file).getFullPath();
}
catch (Exception e)
{
throw convertException(e);
}
}
示例3: saveGameStateSync
import com.google.api.services.drive.model.File; //導入方法依賴的package包/類
/**
* Blocking version of {@link #saveGameState(String, byte[], long, ISaveGameStateResponseListener)}
*
* @param fileId
* @param gameState
* @param progressValue
* @throws IOException
*/
public void saveGameStateSync(String fileId, byte[] gameState, long progressValue) throws IOException {
java.io.File file = java.io.File.createTempFile("games", "dat");
new FileHandle(file).writeBytes(gameState, false);
// no type since it is binary data
FileContent mediaContent = new FileContent(null, file);
// find file on server
File remoteFile = findFileByNameSync(fileId);
// file exists then update it
if (remoteFile != null) {
// just update content, leave metadata intact.
GApiGateway.drive.files().update(remoteFile.getId(), null, mediaContent).execute();
Gdx.app.log(TAG, "File updated ID: " + remoteFile.getId());
}
// file doesn't exists then create it
else {
File fileMetadata = new File();
fileMetadata.setName(fileId);
// app folder is a reserved keyyword for current application private folder.
fileMetadata.setParents(Collections.singletonList("appDataFolder"));
remoteFile = GApiGateway.drive.files().create(fileMetadata, mediaContent)
.setFields("id")
.execute();
Gdx.app.log(TAG, "File created ID: " + remoteFile.getId());
}
}
示例4: 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;
}
示例5: 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();
}
示例6: createFile
import com.google.api.services.drive.model.File; //導入方法依賴的package包/類
public File createFile(String parentId, String name, String mimeType, byte[] content, IProgressMonitor monitor) throws IOException {
File fileMetadata = new File();
fileMetadata.setTitle(name);
fileMetadata.setParents(Arrays.asList(new ParentReference().setId(parentId)));
ByteArrayContent mediaContent = new ByteArrayContent(mimeType, content);
Drive.Files.Insert insert = drive.files().insert(fileMetadata, mediaContent);
MediaHttpUploader uploader = insert.getMediaHttpUploader();
uploader.setDirectUploadEnabled(true);
FileUploadProgressListener uploadProgressListener = new FileUploadProgressListener(monitor);
uploader.setProgressListener(uploadProgressListener);
uploadProgressListener.begin();
try {
fileMetadata = insert.execute();
return fileMetadata;
} finally {
uploadProgressListener.done();
}
}