WIP: Streaming files from service to client
This commit is contained in:
@@ -304,7 +304,7 @@ Public Class EDMIService
|
||||
Public Function ImportFile(FileName As String, Contents() As Byte, AddedWho As String) As DocumentResult2 Implements IEDMIService.ImportFile
|
||||
Dim oDocumentType As String = "DummyDocumentType"
|
||||
Dim oRelativePath As String = EDMIPath.GetRelativePath(oDocumentType, FileName)
|
||||
Dim oAbsolutePath As String = EDMIPath.GetActivePath(oDocumentType)
|
||||
Dim oAbsolutePath As String = EDMIPath.GetActivePath(oDocumentType, FileName)
|
||||
Dim oDirectoryPath = EDMIPath.GetActivePath(oDocumentType)
|
||||
Dim oDocument = New DocumentResult2.DocumentObject With {.FileName = FileName}
|
||||
|
||||
@@ -318,7 +318,7 @@ Public Class EDMIService
|
||||
Try
|
||||
Dim oVersionedFileName As String = Filesystem.GetVersionedFilename(oAbsolutePath)
|
||||
|
||||
_logger.Info("Saving file [{0}] to path [{1}]", FileName, oVersionedFileName)
|
||||
_logger.Info("ImportFile: Saving file [{0}] to path [{1}]", FileName, oVersionedFileName)
|
||||
Using oStream = New FileStream(oVersionedFileName, FileMode.CreateNew)
|
||||
oStream.Write(Contents, 0, Contents.Length)
|
||||
oStream.Flush(True)
|
||||
@@ -344,6 +344,27 @@ Public Class EDMIService
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function GetFileByObjectId(ObjectId As Int64) As Stream Implements IEDMIService.GetFileByObjectId
|
||||
Try
|
||||
Dim oSQL As String = $"SELECT DocRelativePath FROM VWIDB_DOC_DATA WHERE IDB_OBJ_ID = {ObjectId}"
|
||||
Dim oPath As String = MSSQL.GetScalarValue(oSQL)
|
||||
|
||||
If IsNothing(oPath) Then
|
||||
Return Nothing
|
||||
End If
|
||||
|
||||
Dim oFullPath = EDMIPath.GetActivePathFromRelativePath(oPath)
|
||||
|
||||
_logger.Debug("GetFileByObjectId: Loading file [{0}]", oFullPath)
|
||||
|
||||
Dim oSource As FileStream = IO.File.Open(oFullPath, FileMode.Open)
|
||||
Return oSource
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
|
||||
#End Region
|
||||
|
||||
#Region "Index"
|
||||
|
||||
Reference in New Issue
Block a user