本文整理匯總了Java中com.google.api.services.drive.model.File.setName方法的典型用法代碼示例。如果您正苦於以下問題:Java File.setName方法的具體用法?Java File.setName怎麽用?Java File.setName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.api.services.drive.model.File
的用法示例。
在下文中一共展示了File.setName方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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());
}
}
示例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());
}
示例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();
}
示例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);
}
}