/// <summary> /// A blob created from a file uploaded by a client. /// </summary> /// <param name="file">A file uploaded by a client.</param> public Blob(HttpPostedFile file) { this.Name = HString.SafeTrim(Path.GetFileName(file.FileName)); this.BinaryData = HBinary.GetBytes(file.InputStream); this.Size = HNumeric.GetSafeInteger(file.ContentLength); this.MimeType = HString.SafeTrim(file.ContentType); this.State = ObjectState.ToBeInserted; }
/// <summary> /// Modify what data gets binded. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void gvUploads_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { // This is the current row being binded. GridViewRow gridRow = e.Row as GridViewRow; if (gridRow.Cells.Count >= 3) { // Modify file size value to something friendlier. TableCell fileSize = gridRow.Cells[2]; fileSize.Text = HBinary.GetBytesReadable(HNumeric.GetSafeInteger(fileSize.Text)); } } }