6
我有字節流中的媒體內容,並且我試圖在Google雲端硬盤中上傳該流。通過輸入流將字節流上傳到Google Drive
代碼:
private static String writeToGoogleDrive(Drive service, String title,
String description, String parentId, String mimeType,
final byte[] filename) throws IOException {
String URL="";
File body = new File();
body.setTitle(title);
body.setDescription(description);
body.setMimeType(mimeType);
if (parentId != null && parentId.length() > 0) {
body.setParents(Arrays.asList(new ParentReference().setId(parentId)));
}
try {
File file= service.files().insert(body, new AbstractInputStreamContent("") {
@Override
public boolean retrySupported() {
// TODO Auto-generated method stub
return false;
}
@Override
public long getLength() throws IOException {
// TODO Auto-generated method stub
System.out.println("the value of the length of the file is "+filename.length);
return filename.length;
}
@Override
public InputStream getInputStream() throws IOException {
// TODO Auto-generated method stub
return new ByteArrayInputStream(filename);
}
}).execute();
例外:它只是說,空,但我不知道(這)空是什麼。
在這些地方被定義的服務? –