使用api上传的视频文件,文件名是上传日期,参数根据文档设置。这是代码和结果:</p>
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"}