Comments (5)
Is the file a valid video file? It looks like the API was not able to verify the file. Are you able to upload the file via the Google Photos website or a mobile app?
What is the exact codec, dimensions, bit rate, etc. of the file? On Linux, you can use the tool mediainfo
to get a list of details about the file.
from java-photoslibrary.
Is the file a valid video file? It looks like the API was not able to verify the file. Are you able to upload the file via the Google Photos website or a mobile app?
What is the exact codec, dimensions, bit rate, etc. of the file? On Linux, you can use the tool
mediainfo
to get a list of details about the file.
That video is a valid video. I try upload direct from website google photo and application About Backup and Sync was downloaded (https://www.google.com/drive/download/backup-and-sync/) together return success result, but with api return fail.
File test I uploaded to google drive. Please download and try it.
https://drive.google.com/open?id=13NrGvHS1Bq54aRdhq4Ng7ufIKu5lrItt
Hope you soon reply. Thanks!!
from java-photoslibrary.
@hoangdangduy Can you share the snippet of code where you are making the call? Are you setting the filename as well? (That's always recommended when uploading video or image files.)
from java-photoslibrary.
@jfschmakeit I still use code in your repository sample code.
Optional<String> credentialsFile = FileUtils.readFileCredential();
try {
PhotosLibraryClient photosLibraryClient =
PhotosLibraryClientFactory.createClient(credentialsFile.get(), REQUIRED_SCOPES);
// Create a new upload request
// Specify the filename that will be shown to the user in Google Photos
// and the path to the file that will be uploaded
UploadMediaItemRequest uploadRequest = null;
for (DetailFile detailFile: lstDetailFile) {
String path = detailFile.getPath();
String fileName = detailFile.getFileName();
String[] arrSplitFileName = fileName.split("\\.");
try {
RandomAccessFile randomAccessFile = new RandomAccessFile(path, "r");
uploadRequest = UploadMediaItemRequest.newBuilder()
.setFileName(fileName)
.setDataFile(randomAccessFile)
.build();
// Upload and capture the response
UploadMediaItemResponse uploadResponse = photosLibraryClient.uploadMediaItem(uploadRequest);
if (uploadResponse.getError().isPresent()) {
// If the upload results in an error, handle it
UploadMediaItemResponse.Error error = uploadResponse.getError().get();
} else {
// If the upload is successful, get the uploadToken
String uploadToken = uploadResponse.getUploadToken().get();
NewMediaItem newMediaItem = NewMediaItemFactory
.createNewMediaItem(uploadToken, fileName);
List<NewMediaItem> newItems = Arrays.asList(newMediaItem);
BatchCreateMediaItemsResponse response = photosLibraryClient.batchCreateMediaItems(newItems);
randomAccessFile.close();
for (NewMediaItemResult itemsResponse : response.getNewMediaItemResultsList()) {
Status status = itemsResponse.getStatus();
if (status.getCode() == Code.OK_VALUE) {
// The item is successfully created in the user's library
System.out.println("Upload success");
MediaItem createdItem = itemsResponse.getMediaItem();
if (createdItem.getMimeType().compareToIgnoreCase("video/mp4") == 0) {
} else if (createdItem.getMimeType().compareToIgnoreCase("image/png") == 0) {
}
} else {
System.out.println("Upload fail");
}
}
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
} catch (ApiException e) {
e.printStackTrace();
// Handle error
} catch (FileNotFoundException e) {
// Local file could not be found for upload
e.printStackTrace();
} catch (GeneralSecurityException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
from java-photoslibrary.
@jfschmakeit I'm still not yet upload file .mkv done from my code . If you have sample code upload file mkv in project so can it be run show for me. ?
Thanks so much!
from java-photoslibrary.
Related Issues (20)
- Exception passing in video uploading API
- NullPointerException in PhotosLibraryUploadCallable HOT 3
- PhotosLibraryClient close failing
- Can't build a release with 1.5.0 HOT 6
- crash with last version grpc-okhttp (1.31.0) HOT 2
- Base urls expire before 60 minutes HOT 3
- UploadMediaItem fails with cryptic error when the file length is zero HOT 1
- There is a vulnerability in Apache HttpComponents Client(aka Apache HttpClient 4.5.10,upgrade recommended HOT 1
- When deprecated UploadMediaItemRequest.fileName is omitted, Google responds with HTTP 500 HOT 5
- Impossible to interrupt a long-running media item upload if invoked via blocking method
- listMediaItems() method from PhotosLibraryClient.java returns duplicated entries HOT 7
- java.lang.NoClassDefFoundError when attempting to create the PhotosLibraryClient HOT 6
- Add Video Duration to Photos API HOT 1
- Unable to use library with grpc-okhttp
- Credentials expire after 1 hour, how can we refresh? HOT 1
- Security vulnerabilities in protobuf dependency
- Failure to initialize using R8 in full mode on Android HOT 1
- google-java-format plugin is no longer maintained HOT 2
- Java Modularity support?
- Use with Google sign in with Credential Manager
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from java-photoslibrary.