【发布时间】:2018-04-09 16:54:48
【问题描述】:
我正在尝试以编程方式获取我的谷歌驱动器中文件夹的名称并在文件夹内创建一个文件夹,但没有办法。
我已查看此文档:
但是我如何获得一个特定的文件夹并在其中创建另一个文件夹?。以编程方式,而不是通过助手。
好的。我需要将位图更新到谷歌驱动器。我尝试使用此代码但不起作用
String IdFolder = (String) objects[0];
Bitmap bitmapUpload = (Bitmap) objects[1];
File fileMetadata = new File();
fileMetadata.setTitle("photo.jpg");
fileMetadata.setParents(Collections.singletonList(new ParentReference().setId(IdFolder)));
File file = mService.files().insert(fileMetadata, bitmapUpload)
.setFields("id, parents")
.execute();
System.out.println("File ID: " + file.getId());
我试过这个:
String IdFolder = (String) objects[0];
Bitmap bitmapUpload = (Bitmap) objects[1];
int byteSize = bitmapUpload.getRowBytes() * bitmapUpload.getHeight();
ByteBuffer byteBuffer = ByteBuffer.allocate(byteSize);
bitmap.copyPixelsToBuffer(byteBuffer);
byte[] byteArray = byteBuffer.array();
ByteArrayInputStream bs = new ByteArrayInputStream(byteArray);
File fileMetadata = new File();
fileMetadata.setTitle("photo.jpg");
fileMetadata.setParents(Collections.singletonList(new ParentReference().setId(IdFolder)));
File file = mService.files().insert(fileMetadata, bs)
.setFields("id, parents")
.execute();
System.out.println("File ID: " + file.getId());
但不起作用。刚刚说:
com.google.api.client.http.abstract 输入流内容
?¿?
【问题讨论】:
-
也许尝试添加有关错误或每次尝试返回的内容的更多信息。
标签: android google-drive-android-api