Upload Bitmap in Google Drive Api REST

0

I have managed to create folders, create folders within folders with the id ... but I do not know how to upload a bitmap.

I've come this far, but it tells me it's not compatible:

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());

He asks me for this type of object, instead of the BS that I passed him:

  

com.google.api.client.http.abstract inputstreamcontent

    
asked by FireUser 16.04.2018 в 18:36
source

0 answers