Set thumbnail image for uploading on Google Drive

前端 未结 2 944
梦如初夏
梦如初夏 2021-01-27 08:52

I use the following code to set thumb nail for file to upload on Google Drive :

// Set thumb nail path                  
String thumbnail_path =         


        
2条回答
  •  日久生厌
    2021-01-27 09:48

    You decode the data from the getData method that are not encoded.

    You should also use Base64.encodeBase64URLSafeString instead of Base64.encodeBase64String. You can use File.Thumbnail.encodeImage method as a convenience. That will do the encoding for you.

    Replace this:

    byte[] data = Base64.decodeBase64(getData(thumbnail_path));  
    thumbnail.setImage(Base64.encodeBase64String(data));
    

    with this:

    byte[] data = getData(thumbnail_path);  
    thumbnail.encodeImage(data);
    

提交回复
热议问题