Uploading video to Google Drive programmatically (Android API)

前端 未结 5 875
小蘑菇
小蘑菇 2020-12-09 06:40

I have followed the Drive API guide (https://developer.android.com/google/play-services/drive.html) and my app now uploads photos smoothly, but I am now trying to upload vid

5条回答
  •  伪装坚强ぢ
    2020-12-09 07:03

    Without getting into much detail, just a few pointers:

    Anything you want to upload (image, text, video,...) consists from

    1. creating a file
    2. setting metadata (title, MIME type, description,...)
    3. setting content (byte stream)

    The demo you mention does it with an image (JPEG bytestream) and you need to do it with video. So, the changes you need to implement are:

    • replace the "image/jpeg" MIME type with the one you need for your video
    • copy your video stream (outputStream.write(bitmapStream.toByteArray())...)

    to the content.

    These are the only changes you need to make. Google Drive Android API doesn't care what is your content and metadata, it just grabs it a shoves it up to Google Drive.

    In Google Drive, apps (web, android,...) read the metadata and content, and treat it accordingly.

提交回复
热议问题