本文整理匯總了Java中com.google.api.services.drive.model.File.setTitle方法的典型用法代碼示例。如果您正苦於以下問題:Java File.setTitle方法的具體用法?Java File.setTitle怎麽用?Java File.setTitle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.api.services.drive.model.File
的用法示例。
在下文中一共展示了File.setTitle方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: testCopy
import com.google.api.services.drive.model.File; //導入方法依賴的package包/類
@Test
public void testCopy() throws Exception {
File testFile = uploadTestFile();
String fromFileId = testFile.getId();
File toFile = new File();
toFile.setTitle(UPLOAD_FILE.getName() + "_copy");
final Map<String, Object> headers = new HashMap<String, Object>();
// parameter type is String
headers.put("CamelGoogleDrive.fileId", fromFileId);
// parameter type is com.google.api.services.drive.model.File
headers.put("CamelGoogleDrive.content", toFile);
final File result = requestBodyAndHeaders("direct://COPY", null, headers);
assertNotNull("copy result", result);
assertEquals(toFile.getTitle(), result.getTitle());
LOG.debug("copy: " + result);
}
示例4: testPatch
import com.google.api.services.drive.model.File; //導入方法依賴的package包/類
@Test
public void testPatch() throws Exception {
File file = uploadTestFile();
// lets update the filename
file.setTitle(UPLOAD_FILE.getName() + "PATCHED");
final Map<String, Object> headers = new HashMap<String, Object>();
// parameter type is String
headers.put("CamelGoogleDrive.fileId", file.getId());
// parameter type is String
headers.put("CamelGoogleDrive.fields", "title");
// parameter type is com.google.api.services.drive.model.File
headers.put("CamelGoogleDrive.content", file);
File result = requestBodyAndHeaders("direct://PATCH", null, headers);
assertNotNull("patch result", result);
assertEquals(UPLOAD_FILE.getName() + "PATCHED", result.getTitle());
LOG.debug("patch: " + result);
}
示例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;
}
示例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();
}
示例7: 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();
}
}
示例8: uploadTestFile
import com.google.api.services.drive.model.File; //導入方法依賴的package包/類
protected File uploadTestFile() {
File fileMetadata = new File();
fileMetadata.setTitle(UPLOAD_FILE.getName());
FileContent mediaContent = new FileContent(null, UPLOAD_FILE);
final Map<String, Object> headers = new HashMap<String, Object>();
// parameter type is com.google.api.services.drive.model.File
headers.put("CamelGoogleDrive.content", fileMetadata);
// parameter type is com.google.api.client.http.AbstractInputStreamContent
headers.put("CamelGoogleDrive.mediaContent", mediaContent);
File result = requestBodyAndHeaders("google-drive://drive-files/insert", null, headers);
return result;
}
示例9: 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;
}
示例10: testInsert
import com.google.api.services.drive.model.File; //導入方法依賴的package包/類
@Test
public void testInsert() throws Exception {
File file = new File();
file.setTitle(UPLOAD_FILE.getName());
// using com.google.api.services.drive.model.File message body for single parameter "content"
File result = requestBody("direct://INSERT", file);
assertNotNull("insert result", result);
LOG.debug("insert: " + result);
}
示例11: testUpdate1
import com.google.api.services.drive.model.File; //導入方法依賴的package包/類
@Test
public void testUpdate1() throws Exception {
// First retrieve the file from the API.
File testFile = uploadTestFile();
String fileId = testFile.getId();
// using String message body for single parameter "fileId"
final File file = requestBody("direct://GET", fileId);
// File's new metadata.
file.setTitle("camel.png");
// File's new content.
java.io.File fileContent = new java.io.File(TEST_UPLOAD_IMG);
FileContent mediaContent = new FileContent(null, fileContent);
// Send the request to the API.
final Map<String, Object> headers = new HashMap<String, Object>();
// parameter type is String
headers.put("CamelGoogleDrive.fileId", fileId);
// parameter type is com.google.api.services.drive.model.File
headers.put("CamelGoogleDrive.content", file);
// parameter type is com.google.api.client.http.AbstractInputStreamContent
headers.put("CamelGoogleDrive.mediaContent", mediaContent);
File result = requestBodyAndHeaders("direct://UPDATE_1", null, headers);
assertNotNull("update result", result);
LOG.debug("update: " + result);
}