I'm using the latest Java SDK for Google Drive (1.9.0 rev 155) and I have managed to make it work to upload files, list them, create directories (which is suprisingly hard), and other various things.
But the content I upload is invisible in the Web interface, and similarly the content in the Web interface is invisible to my code. The code is as such:
public final class Main
{
private static final String APPLICATION_NAME = "java7-fs-gdrive";
private static final JsonFactory JSON_FACTORY
= JacksonFactory.getDefaultInstance();
private static final Path SECRETS_FILE;
static {
final String home = System.getProperty("user.home");
if (home == null)
throw new ExceptionInInitializerError("user.home not defined???");
final Path clientSecrets
= Paths.get(home, ".gdrive/clientSecrets.json");
try {
SECRETS_FILE = clientSecrets.toRealPath();
} catch (IOException e) {
throw new ExceptionInInitializerError(e);
}
}
private Main()
{
throw new Error("nice try!");
}
public static void main(final String... args)
throws GeneralSecurityException, IOException
{
final NetHttpTransport transport
= GoogleNetHttpTransport.newTrustedTransport();
final GoogleCredential credential;
try (
final InputStream in = Files.newInputStream(SECRETS_FILE);
) {
credential = GoogleCredential.fromStream(in, transport,
JSON_FACTORY).createScoped(ImmutableList.of(DriveScopes.DRIVE));
}
final Drive drive = new Drive.Builder(transport, JSON_FACTORY,
credential).setApplicationName(APPLICATION_NAME).build();
final Drive.Files files = drive.files();
final Drive.Files.List list = files.list();
final FileList fileList = list.execute();
final List<File> items = fileList.getItems();
for (final File item: items) {
System.out.println(item.getTitle());
System.out.println(item.getId());
System.out.println(item.getKind());
}
}
}
OK, so, from the developer console, what I use is a "service account" credentials file. There are also "client ID for web applications". And after many reading trips to the developer site (and SO questions/answers) I still cannot figure out the difference between the two and still cannot figure out how to modify the files "on the web UI".
So, what should I do?