
/*** Calculate a signature*/function createFileUploadSignature({ timeStamp = 86400, procedure = '', classId = 0, oneTimeValid = 0, sourceContext = '' }) {// Determine the generation time and expiration time of the signaturelet current = parseInt((new Date()).getTime() / 1000)let expired = current + timeStamp; // Signature validity period: 1 day// Enter the parameters into the parameter listlet arg_list = {//requiredsecretId: this.conf.SecretId,currentTimeStamp: current,expireTime: expired,random: Math.round(Math.random() * Math.pow(2, 32)),//optsprocedure,classId,oneTimeValid,sourceContext}// Calculate the signaturelet orignal = querystring.stringify(arg_list);let orignal_buffer = new Buffer(orignal, "utf8");let hmac = crypto.createHmac("sha1", this.conf.SecretKey);let hmac_buffer = hmac.update(orignal_buffer).digest();let signature = Buffer.concat([hmac_buffer, orignal_buffer]).toString("base64");return signature;}/*** Respond to a signature request*/function getUploadSignature(req, res) {res.json({code: 0,message: 'ok',data: {signature: gVodHelper.createFileUploadSignature({})}});}

TXUGCRecord API to shoot a short video, and a .mp4 short video file will be generated after the shoot ends and be called back.TXUGCPublish API to publish the video. After the video is successfully published, the SDK will call back the watch URL to you.SecretID or SecretKey for upload signature calculation into the client code of the application, as their disclosure will cause security risks. If attackers get such information by cracking the application, they can misappropriate your traffic and storage service.SecretID and SecretKey on your server and send the signature to the application. As the server is generally hard to be intruded, the security is guaranteed.Signature field is correctly passed in; otherwise, the release will fail.TXVideoEditer.generateVideo(int videoCompressed, String videoOutputPath) API to compress the selected video. Four resolutions are supported for compression currently, and compression with customizable bitrate will be supported in the future.TXUGCPublish (in TXUGCPublish.h) is used to publish .mp4 files to VOD so as to meet various video watch needs such as nearby scheduling, instant live streaming and playback, dynamic acceleration, and global connection.TXPublishParam * param = [[TXPublishParam alloc] init];param.signature = _signature; // Enter the upload signature calculated in step 4// Video file path generated by shoot, which can be obtained through the `onRecordComplete` callback of `TXVideoRecordListener`param.videoPath = _videoPath;// Path of the first-frame video preview image generated by shoot. The value is the file path specified by calling `startRecord`. You can also specify a path and save the `UIImage` obtained in the `onRecordComplete` callback of `TXVideoRecordListener` to the specified path. It can be set to `nil`.param.coverPath = _coverPath;TXUGCPublish *_ugcPublish = [[TXUGCPublish alloc] init];// Checkpoint restart is used for file release by default_ugcPublish.delegate = self; // Set the `TXVideoPublishListener` callback[_ugcPublish publishVideo:param];
TXVideoPublishListener API (defined in the TXUGCPublishListener.h header file):onPublishProgress is used to return the file release progress, the uploadBytes parameter indicates the number of uploaded bytes, and the totalBytes parameter indicates the total number of bytes that need to be uploaded.@optional-(void) onPublishProgress:(NSInteger)uploadBytes totalBytes: (NSInteger)totalBytes;
onPublishComplete is used to return the release result, the errCode and descMsg fields of TXPublishResult indicate the error code and error message respectively, videoURL indicates the VOD address of the short video, coverURL indicates the cloud storage address of the video cover, and videoId indicates the cloud storage ID the video file, with which you can call VOD's server APIs.@optional-(void) onPublishComplete:(TXPublishResult*)result;
fileId, playback URL, and cover URL will be returned. You can directly pass in the fileId or playback URL to the VOD player for playback.Feedback