EDMI: First version of Updating files by replacing them!
This commit is contained in:
@@ -21,25 +21,56 @@ Namespace Methods.IDB.UpdateFile
|
||||
|
||||
Public Function Run(pData As UpdateFileRequest) As UpdateFileResponse
|
||||
|
||||
' TODO: Update file object
|
||||
If Helpers.TestObjectIdExists(pData.ObjectId) = False Then
|
||||
LogAndThrow("ObjectId does not exist!")
|
||||
End If
|
||||
Try
|
||||
' TODO: Update file object
|
||||
If Helpers.TestObjectIdExists(pData.ObjectId) = False Then
|
||||
LogAndThrow("ObjectId does not exist!")
|
||||
End If
|
||||
|
||||
'TODO: Create a view that collects all information about an idb object
|
||||
'TODO: Create a view that collects all information about an idb object
|
||||
|
||||
If pData.CreateNewVersion = False Then
|
||||
If pData.CreateNewVersion = False Then
|
||||
Dim oGetFileObject As New GetFileObject.GetFileObjectMethod(LogConfig, DatabaseIDB, DatabaseECM, GlobalState)
|
||||
Dim oArgs = New GetFileObject.GetFileObjectRequest With {
|
||||
.ObjectId = pData.ObjectId,
|
||||
.LoadFileContents = False
|
||||
}
|
||||
Dim oFileObjectResponse As GetFileObject.GetFileObjectResponse = oGetFileObject.Run(oArgs)
|
||||
|
||||
If oFileObjectResponse.OK = False Then
|
||||
LogAndThrow(oFileObjectResponse.ErrorMessage)
|
||||
End If
|
||||
|
||||
Dim oFileObjectSize As Long = pData.File.FileContents.Length
|
||||
Dim oFileObject As GetFileObject.FileObject = oFileObjectResponse.FileObject
|
||||
Dim oFilePath As String = oFileObject.FilePath
|
||||
|
||||
Try
|
||||
Using oStream = New IO.FileStream(oFilePath, IO.FileMode.Create, IO.FileAccess.Write)
|
||||
Logger.Info("Saving file to path [{0}]", oFilePath)
|
||||
oStream.Write(pData.File.FileContents, 0, oFileObjectSize)
|
||||
oStream.Flush(True)
|
||||
oStream.Close()
|
||||
End Using
|
||||
Catch ex As Exception
|
||||
LogAndThrow(ex, $"Could not write file [{oFilePath}] to disk!")
|
||||
End Try
|
||||
|
||||
Return New UpdateFileResponse(pData.ObjectId)
|
||||
|
||||
Else
|
||||
Throw New ApplicationException("Not implemented!!")
|
||||
|
||||
|
||||
Else
|
||||
End If
|
||||
|
||||
End If
|
||||
Catch ex As Exception
|
||||
Return New UpdateFileResponse(ex)
|
||||
|
||||
End Try
|
||||
|
||||
|
||||
|
||||
|
||||
Return New UpdateFileResponse(pData.ObjectId)
|
||||
|
||||
'Dim oFilePath As String = Nothing
|
||||
'
|
||||
'Dim oExistingObjectId = TestFileChecksumExists(pData.File.FileChecksum)
|
||||
|
||||
Reference in New Issue
Block a user