public BCImage GetBCImage() { BCImage img = new BCImage(); img.displayName = this.ImageName; img.referenceId = this.ReferenceID; img.type = this.Type; return(img); }
protected void btnAddImage_Click(object sender, EventArgs e) { BCImage newImg = iaAdd.GetBCImage(); RPCResponse <BCImage> rpcr = bc.AddImage(newImg, iaAdd.FileName, iaAdd.FileBytes, currentItem.VideoID, iaAdd.Resize); if (rpcr.error.message != null) { pnlImageMessage.Visible = true; ltlImageMessage.Text = rpcr.error.code + ": " + rpcr.error.message; } else { pnlImageMessage.Visible = true; ltlImageMessage.Text = "The image has been uploaded to Brightcove."; } iaAdd.ClearForm(); }
/// <summary> /// Add a new thumbnail or video still image to a video, or assign an existing image to another video. /// </summary> /// <param name="image"> /// The metadata for the image you'd like to create (or update). This takes the form of a /// JSON object of name/value pairs, each of which corresponds to a property of the Image object. /// </param> /// <param name="filename"> /// The name of the file that's being uploaded. You don't need to specify this in the JSON /// if it is specified in the file part of the POST. /// </param> /// <param name="maxsize"> /// The maximum size that the file will be. This is used as a limiter to know when something /// has gone wrong with the upload. The maxSize is same as the file you uploaded. You don't /// need to specify this in the JSON if it is specified in the file part of the POST. /// </param> /// <param name="file"> /// An input stream associated with the image file you're uploading. This takes the form of a /// file part, in a multipart/form-data HTTP request. This input stream and the filename and /// maxSize parameters are automatically inferred from that file part. /// </param> /// <param name="file_checksum"> /// An optional MD5 hash of the file. The checksum can be used to verify that the file checked /// into your Brightcove Media Library is the same as the file you uploaded. /// </param> /// <param name="video_id"> /// The ID of the video you'd like to assign an image to. /// </param> /// <param name="video_reference_id"> /// The publisher-assigned reference ID of the video you'd like to assign an image to. /// </param> /// <param name="resize"> /// Set this to false if you don't want your image to be automatically resized to the default /// size for its type. By default images will be resized. /// </param> /// <returns></returns> private RPCResponse <BCImage> AddImage(BCImage image, string filename, byte[] file, long video_id, string video_reference_id, bool resize, long maxsize, string file_checksum) { // Generate post objects Dictionary <string, object> postParams = new Dictionary <string, object>(); //add video to the post params RPCRequest rpc = new RPCRequest(); rpc.method = "add_image"; rpc.parameters = "\"image\": " + image.ToJSON(); rpc.parameters += ", \"filename\": \"" + filename + "\""; if (video_id > -1) { rpc.parameters += ",\"video_id\": \"" + video_id.ToString() + "\""; } else if (video_reference_id != null) { rpc.parameters += ",\"video_reference_id\": \"" + video_reference_id + "\""; } if (maxsize > -1) { rpc.parameters += ", \"maxsize\": \"" + maxsize.ToString() + "\""; } if (file_checksum != null) { rpc.parameters += ", \"file_checksum\": \"" + file_checksum + "\""; } rpc.parameters += ", \"token\": \"" + Account.WriteToken.Value + "\""; postParams.Add("json", rpc.ToJSON()); //add the file to the post if (file != null && !string.IsNullOrEmpty(filename)) { postParams.Add("file", new FileParameter(file, filename)); } //Get the JSon reader returned from the APIRequest RPCResponse <BCImage> rpcr = BCAPIRequest.ExecuteWrite <BCImage>(postParams, Account); return(rpcr); }
protected bool AddImage(HttpPostedFile file, ImageTypeEnum imageType, string remoteUrl) { if ((file != null) && !string.IsNullOrEmpty(file.FileName)) { byte[] buffer = new byte[file.InputStream.Length]; BCImage image = new BCImage(); RPCResponse <BCImage> result = null; file.InputStream.Read(buffer, 0, buffer.Length); image.type = imageType; image.remoteUrl = remoteUrl; image.id = this.video.id; image.displayName = Path.GetFileName(file.FileName);; result = this.bcApi.AddImage(image, image.displayName, buffer, this.video.id, true); if ((result.error.code != null) || (result.error.message != null)) { return(false); } } return(true); }
//using ref id public RPCResponse <BCImage> AddImage(BCImage image, string filename, byte[] file, string video_reference_id) { return(AddImage(image, filename, file, video_reference_id, true)); }
public RPCResponse <BCImage> AddImage(BCImage image, string filename, byte[] file, long video_id, bool resize, long maxsize) { return(AddImage(image, filename, file, video_id, resize, maxsize, null)); }
protected bool AddImage(HttpPostedFile file, ImageTypeEnum imageType, string remoteUrl) { if ((file != null) && !string.IsNullOrEmpty(file.FileName)) { byte[] buffer = new byte[file.InputStream.Length]; BCImage image = new BCImage(); RPCResponse<BCImage> result = null; file.InputStream.Read(buffer, 0, buffer.Length); image.type = imageType; image.remoteUrl = remoteUrl; image.id = this.video.id; image.displayName = Path.GetFileName(file.FileName);; result = this.bcApi.AddImage(image, image.displayName, buffer, this.video.id, true); if ((result.error.code != null) || (result.error.message != null)) { return false; } } return true; }
/// <summary> /// Add a new thumbnail or video still image to a video, or assign an existing image to another video. /// </summary> /// <param name="image"> /// The metadata for the image you'd like to create (or update). This takes the form of a /// JSON object of name/value pairs, each of which corresponds to a property of the Image object. /// </param> /// <param name="filename"> /// The name of the file that's being uploaded. You don't need to specify this in the JSON /// if it is specified in the file part of the POST. /// </param> /// <param name="maxsize"> /// The maximum size that the file will be. This is used as a limiter to know when something /// has gone wrong with the upload. The maxSize is same as the file you uploaded. You don't /// need to specify this in the JSON if it is specified in the file part of the POST. /// </param> /// <param name="file"> /// An input stream associated with the image file you're uploading. This takes the form of a /// file part, in a multipart/form-data HTTP request. This input stream and the filename and /// maxSize parameters are automatically inferred from that file part. /// </param> /// <param name="file_checksum"> /// An optional MD5 hash of the file. The checksum can be used to verify that the file checked /// into your Brightcove Media Library is the same as the file you uploaded. /// </param> /// <param name="video_id"> /// The ID of the video you'd like to assign an image to. /// </param> /// <param name="video_reference_id"> /// The publisher-assigned reference ID of the video you'd like to assign an image to. /// </param> /// <param name="resize"> /// Set this to false if you don't want your image to be automatically resized to the default /// size for its type. By default images will be resized. /// </param> /// <returns></returns> private RPCResponse<BCImage> AddImage(BCImage image, string filename, byte[] file, long video_id, string video_reference_id, bool resize, long maxsize, string file_checksum) { // Generate post objects Dictionary<string, object> postParams = new Dictionary<string, object>(); //add video to the post params RPCRequest rpc = new RPCRequest(); rpc.method = "add_image"; rpc.parameters = "\"image\": " + image.ToJSON(); rpc.parameters += ", \"filename\": \"" + filename + "\""; if (video_id > -1) { rpc.parameters += ",\"video_id\": \"" + video_id.ToString() + "\""; } else if (video_reference_id != null) { rpc.parameters += ",\"video_reference_id\": \"" + video_reference_id + "\""; } if (maxsize > -1) { rpc.parameters += ", \"maxsize\": \"" + maxsize.ToString() + "\""; } if (file_checksum != null) { rpc.parameters += ", \"file_checksum\": \"" + file_checksum + "\""; } rpc.parameters += ", \"token\": \"" + Account.WriteToken.Value + "\""; postParams.Add("json", rpc.ToJSON()); //add the file to the post postParams.Add("file", new FileParameter(file, filename)); //Get the JSon reader returned from the APIRequest RPCResponse<BCImage> rpcr = BCAPIRequest.ExecuteWrite<BCImage>(postParams, Account); return rpcr; }
public RPCResponse<BCImage> AddImage(BCImage image, string filename, byte[] file, string video_reference_id, bool resize, long maxsize, string file_checksum) { return AddImage(image, filename, file, -1, video_reference_id, resize, maxsize, file_checksum); }
//using video id public RPCResponse<BCImage> AddImage(BCImage image, long video_id) { return AddImage(image, "", video_id); }
public BitmapParticle(BCPoint pPosition, BCPoint pVelocity, BCColor pColor, BCImage img) : base(pPosition, pVelocity, pColor) { Image = img; }
public GameOverStatisticColumnData(BCImage CellImage, HorizontalAlignment hAlign = HorizontalAlignment.Left, VerticalAlignment vAlign = VerticalAlignment.Top) { this.InfoType = CellType.Image; this.CellImage = CellImage; }
public RPCResponse <BCImage> AddImage(BCImage image, string filename, byte[] file, string video_reference_id, bool resize) { return(AddImage(image, filename, file, video_reference_id, resize, -1)); }
public RPCResponse <BCImage> AddImage(BCImage image, string filename, string video_reference_id) { return(AddImage(image, filename, null, video_reference_id)); }
//using ref id public RPCResponse <BCImage> AddImage(BCImage image, string video_reference_id) { return(AddImage(image, "", video_reference_id)); }
//using video id public RPCResponse <BCImage> AddImage(BCImage image, long video_id) { return(AddImage(image, "", video_id)); }
public RPCResponse<BCImage> AddImage(BCImage image, string filename, string video_reference_id) { return AddImage(image, filename, null, video_reference_id); }
//using ref id public RPCResponse<BCImage> AddImage(BCImage image, string video_reference_id) { return AddImage(image, "", video_reference_id); }
public RPCResponse <BCImage> AddImage(BCImage image, string filename, byte[] file, string video_reference_id, bool resize, long maxsize, string file_checksum) { return(AddImage(image, filename, file, -1, video_reference_id, resize, maxsize, file_checksum)); }
public RPCResponse<BCImage> AddImage(BCImage image, string filename, byte[] file, long video_id, bool resize, long maxsize) { return AddImage(image, filename, file, video_id, resize, maxsize, null); }
public StatisticInfoColumnInfoImage(BCImage pImage, HorizontalStatisticAlignment pH, VerticalStatisticAlignment pV) : base(pH, pV) { CellImage = pImage; }
//using ref id public RPCResponse<BCImage> AddImage(BCImage image, string filename, byte[] file, string video_reference_id) { return AddImage(image, filename, file, video_reference_id, true); }
public BCImage GetBCImage() { BCImage img = new BCImage(); img.displayName = this.ImageName; img.referenceId = this.ReferenceID; img.type = this.Type; return img; }
public RPCResponse<BCImage> AddImage(BCImage image, string filename, byte[] file, string video_reference_id, bool resize) { return AddImage(image, filename, file, video_reference_id, resize, -1); }