Kaltura 文件上传 API

Kaltura File Upload API

我必须使用 java kaltura api 上传文件。我已经搜索了很多,但找不到任何帮助文档。如果有人知道如何使用 java.

在 kaltura 中上传文件,请帮助我

我得到了一个用于文件上传的C#API,希望对你有所帮助。

KalturaClient  kalturaClient = KalturaUtilsService.getKalturaClient();
            KalturaMediaEntry kalturaMediaEntry = new KalturaMediaEntry();


            kalturaMediaEntry.name = "Java Entry Using C#";
            kalturaMediaEntry.mediaType = KalturaMediaType.VIDEO;
            kalturaMediaEntry = kalturaClient.getMediaService().add(kalturaMediaEntry);
            FileStream fileStream = new FileStream("/home/alok/Desktop/index.mp4", FileMode.Open, FileAccess.Read);
            KalturaUploadToken uploadToken = kalturaClient.UploadTokenService.Add();
            kalturaClient.UploadTokenService.Upload(uploadToken.Id, fileStream);

            KalturaUploadedFileTokenResource mediaResource = new KalturaUploadedFileTokenResource();
            mediaResource.Token = uploadToken.Id;
            kalturaMediaEntry = kalturaClient.MediaService.AddContent(kalturaMediaEntry.Id, mediaResource);

提前致谢!!!

java 客户端库 (http://www.kaltura.com/api_v3/testme/client-libs.php) 提供了一个示例,您可以在 src/Kaltura.java 下找到它,方法 uploadMediaFileAndAttachToEmptyEntry

这是一个简化版本:

String adminSecret = "API-ADMIN-SECRET";
Integer partnerId = PARTNER_ID;
String filePath = "src/DemoVideo.flv";
String uploadUserId = "TestUploader";

// initialize the client
KalturaConfiguration config = new KalturaConfiguration();
config.setEndpoint("http://www.kaltura.com/");
KalturaClient client = new KalturaClient(config);
String ks = client.generateSession(adminSecret, uploadUserId, KalturaSessionType.ADMIN, partnerId);
client.setKs(ks);

// add the media entry
KalturaMediaEntry mediaEntry = new KalturaMediaEntry();
mediaEntry.name = "Uploaded Media";
mediaEntry.mediaType = KalturaMediaType.VIDEO;
mediaEntry = client.getMediaService().add(mediaEntry);

// add the upload token
KalturaUploadToken uploadToken = new KalturaUploadToken();
uploadToken = client.getUploadTokenService().add(uploadToken);

// initialize the file
File file = new File(filePath);

// upload the file
client.getUploadTokenService().upload(uploadToken.id, file);

// link between the file and the media entry
KalturaUploadedFileTokenResource uploadedFileTokenResource = new KalturaUploadedFileTokenResource();
uploadedFileTokenResource.token = uploadToken.id;
client.getMediaService().addContent(mediaEntry.id, uploadedFileTokenResource);