java - Uploading byte stream to Google Drive via input stream -


i have media content in byte stream, , attempting upload stream in google drive.

code :

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 length of file "+filename.length);                 return filename.length;             }              @override             public inputstream getinputstream() throws ioexception {                 // todo auto-generated method stub                 return new bytearrayinputstream(filename);             }          }).execute(); 

exception: says null, don't know (that) null is.

you can try this:

file = service.files().insert(body, new inputstreamcontent(mimetype,  new bytearrayinputstream(filename))).execute(); 

Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -