升级视频使用google-photos-api

时间:2018-10-10 07:25:26

标签: google-photos google-photos-api

使用api上传的视频文件,文件名是上传日期,根据文档设置参数。这是代码和结果:

 String url = "https://photoslibrary.googleapis.com/v1/uploads";
         HttpPost post = new HttpPost(url);
         String accessToken="xxxxxxxxx";
         String fileName = "testVideo.mp4";
         File localFile = new File("xxxxxxxxx");
         post.addHeader("Content-Type","application/octet-stream");
         post.addHeader("Authorization", "Bearer "+accessToken);
         post.addHeader("X-Goog-Upload-File-Name",fileName);
         post.addHeader("X-Goog-Upload-Protocol", "raw");
         InputStream in = new FileInputStream(localFile);
         InputStreamEntity streamEntity = new InputStreamEntity(in);
         post.setEntity(streamEntity);
         excute(post);
        {"id":"ADKWk0uTzr_2wTrcWQpJzx4jZtBOMZlv3ujqkuFIOODpdT4TUpZWRqk20ZZEzbmKLBrW4IYb7db7YAHY4Sok1BQZs8sOQM9-Ow","productUrl":"https://photos.google.com/lr/album/ADKWk0u9Ksoym4niRU9oj1W-","mimeType":"video/mp4","mediaMetadata":{"creationTime":"2017-07-13T10:51:08Z","width":"960","height":"544","video":{"fps":29.9,"status":"READY"}},"filename":"2018-10-09"}

1 个答案:

答案 0 :(得分:0)

API当前存在一个问题,即视频上传的文件名设置不正确。您可以在问题跟踪器上关注此问题:https://issuetracker.google.com/114462217

(您可以为问题加注星标,以便进行任何更新。)