
Hi
I am using file upload control to store the files in SQL Tables.
public void OnUploadCompleted()
{
System.IO.Stream stream;
FileUploadTemporaryStorageResult result = this.getFileUploadResult() as FileUploadTemporaryStorageResult;
container con;
ProjectAttachments HcmAbsenceRequestAttachmentTmpInsert;
super();
if (result && result.getUploadStatus())
{
fileUrl = result.getDownloadUrl();
stream = result.openResult();
con = Binary::constructFromMemoryStream(stream).getContainer();
HcmAbsenceRequestAttachmentTmpInsert.clear();
HcmAbsenceRequestAttachmentTmpInsert.AttachmentName = result.getFileName();
HcmAbsenceRequestAttachmentTmpInsert.AttachmentContent = con;
HcmAbsenceRequestAttachmentTmpInsert.ProjId = projid;
HcmAbsenceRequestAttachmentTmpInsert.Author = HcmWorker::userId2Worker(curUserId());
HcmAbsenceRequestAttachmentTmpInsert.Created = DateTimeUtil::getSystemDateTime();
//HcmAbsenceRequestAttachmentTmpInsert.Path = fileUrl;
HcmAbsenceRequestAttachmentTmpInsert.ContentType = result.getFileContentType();
HcmAbsenceRequestAttachmentTmpInsert.insert();
element.close();
}
}
I am displaying all the files into the grid. When I click download on particular row, the file should be downloaded.
Options already tried
BinData b = new BinData();
b.setData(HcmAbsenceRequestAttachmentTmpInsert.AttachmentContent);
b.saveFile(@"C:\Temp\"+DocuRef1_.AttachmentName); But this option will not let the user to select the file directory
Thanks
Pradeep
Use File::sendFindToUser(). Like this:
Binary binary = Binary::constructFromContainer(table.AttachmentContent); System.Io.Stream stream = binary.getMemoryStream(); File::sendFindToUser(stream, table.AttachmentName);
By the way, you should avoid storing large files in the relational database. Database storage is limited and (relatively) expensive.