public static Pair<String, Long> uploadVideo(
      UUID jobId,
      VideoModel video,
      PhotosLibraryClient photosLibraryClient,
      TemporaryPerJobDataStore dataStore,
      ConnectionProvider connectionProvider)
      throws IOException, UploadErrorException, InvalidTokenException {

    final File tmp = createTempFile(
        jobId,
        dataStore,
        connectionProvider,
        video);
    try {
      UploadMediaItemRequest uploadRequest =
          UploadMediaItemRequest.newBuilder()
              .setFileName(video.getName())
              .setDataFile(new RandomAccessFile(tmp, "r"))
              .build();
      UploadMediaItemResponse uploadResponse = photosLibraryClient.uploadMediaItem(uploadRequest);
      String uploadToken;
      if (uploadResponse.getError().isPresent() || !uploadResponse.getUploadToken().isPresent()) {
        Error error = uploadResponse.getError().orElse(null);

        if (error != null) {
          Throwable cause = error.getCause();
          String message = cause.getMessage();
          if (message.contains("The upload url is either finalized or rejected by the server")) {
            throw new UploadErrorException("Upload was terminated because of error", cause);
          } else if (isTokenException(message)) {
            throw new InvalidTokenException("Token has been expired or revoked", cause);
          }
        }

        throw new IOException(
            "An error was encountered while uploading the video.",
            error != null ? error.getCause() : null);
      } else {
        uploadToken = uploadResponse.getUploadToken().get();
      }
      return Pair.of(uploadToken, tmp.length());
    } catch (ApiException ex) {
      // temp check as exception is not captured and wrapped into UploadMediaItemResponse
      Throwable cause = ex.getCause();
      String message = cause.getMessage();
      if (isTokenException(message)) {
        throw new InvalidTokenException("Token has been expired or revoked", cause);
      }
      throw new IOException("An error was encountered while uploading the video.", cause);
    } finally {
      //noinspection ResultOfMethodCallIgnored
      tmp.delete();
    }
  }
Uploads `video` via {@link com.google.photos.library.v1.PhotosLibraryClient} APIs.

Returns an upload token, and a byte count of the video that was uploaded.
extensions/data-transfer/portability-data-transfer-google/src/main/java/org/datatransferproject/datatransfer/google/videos/GoogleVideosInterface.java