/** uploads a video file to Kaltura and assigns it to a given Media Entry object */
  private static void uploadMediaFileAndAttachToEmptyEntry(KalturaMediaEntry entry)
      throws KalturaApiException {
    KalturaClient client = getKalturaClient();
    System.out.println("Uploading a video file...");

    // upload upload token
    KalturaUploadToken upToken = client.getUploadTokenService().add();
    KalturaUploadedFileTokenResource fileTokenResource = new KalturaUploadedFileTokenResource();

    // Connect to media entry and update name
    fileTokenResource.token = upToken.id;
    entry = client.getMediaService().addContent(entry.id, fileTokenResource);

    // Upload actual data
    try {
      InputStream fileData = TestUtils.getTestVideo();
      int fileSize = fileData.available();

      client
          .getUploadTokenService()
          .upload(upToken.id, fileData, testConfig.getUploadVideo(), fileSize);

      System.out.println("Uploaded a new Video file to entry: " + entry.id);
    } catch (FileNotFoundException e) {
      System.out.println("Failed to open test video file");
    } catch (IOException e) {
      System.out.println("Failed to read test video file");
    }
  }
  /** uploads a video file to Kaltura and assigns it to a given Media Entry object */
  private static void uploadMediaFileByChunkAndAttachToEmptyEntry(KalturaMediaEntry entry)
      throws KalturaApiException {
    KalturaClient client = getKalturaClient();
    System.out.println("Uploading a video file...");

    // upload upload token
    KalturaUploadToken upToken = client.getUploadTokenService().add();

    try {
      String TAG = "test-upload-large-files";
      UploadToken uploadToken = new UploadToken(TAG, 5, client);
      String path = testConfig.getUploadVideo();
      System.out.println("Trying to upload " + path);
      uploadToken.setStartUpload(true);
      uploadToken.uploadMediaFileAndAttachToEmptyEntry(TAG, entry, path);

      System.out.println("Uploaded a new Video file to entry: " + entry.id);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }