Interface IFileFieldService
Represents the file field API service. Exposes methods for downloading and uploading files linked to file fields.
Namespace: Relativity.Testing.Framework.Api.Services
Assembly: Relativity.Testing.Framework.Api.dll
Syntax
public interface IFileFieldService
Examples
_fileFieldService = relativityFacade.Resolve<IFileFieldService>();
Methods
| Improve this Doc View SourceDownloadFile(Int32, FileFieldDTO)
Downloads a file from a file field.
Declaration
FileFieldDTO DownloadFile(int workspaceId, FileFieldDTO fileFieldDto)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | workspaceId | The workspace ID. |
FileFieldDTO | fileFieldDto | The FileFieldDTO containing information about the File Field of the file to download. Must contain ArtifactId or Name of the Field and ObjectRef as well as FileStream that can be written. |
Returns
Type | Description |
---|---|
FileFieldDTO | FileField object containing downloaded file. |
Examples
var workspaceId = -1;
var objectRef = relativityFacade.Resolve<IObjectService>()
.Query<SomeObjectType>()
.Where(x => x.Name, "SomeObjectName");
var fileField = new FileField // This field should exist and have object of the objectRef above (Some Object Type)
{
Name = "Some File Field Name" // Can also have ArtifactId filled instead of Name
};
var fileField = new FileField
{
Field = fileField,
ObjectRef = objectRef,
FileStream = new MemoryStream();
};
var result = _sut.DownloadFile(workspaceId, fileFieldDto);
using (result.FileStream)
{
Assert.That(result.FileStream.Length > 0);
}
Exceptions
Type | Condition |
---|---|
System.ArgumentException | The fileFieldDto does not contain all needed data. |
UploadFile(Int32, FileFieldDTO)
Uploads a file to the file field. Saves the objects with the uploadd file.
Declaration
FileFieldDTO UploadFile(int workspaceId, FileFieldDTO fileFieldDto)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | workspaceId | The workspace ID. |
FileFieldDTO | fileFieldDto | The FileFieldDTO containing information about the File Field, file name and filestream with the file to upload. Must contain ArtifactId or Name of the Field and ObjectRef. |
Returns
Type | Description |
---|---|
FileFieldDTO | FileField object containing the GUID of the uploaded file. |
Examples
var workspaceId = -1;
var someExstingFileFieldArtifactId = 1;
var = new FileField // This field should exist and have object of the objectRef below (Some Object Type)
{
ArtifactId = someExstingFileFieldArtifactId // Can also have Name filled instead of ArtifactId
};
var objectRef = relativityFacade.Resolve<IObjectService>()
.Query<SomeObjectType>()
.Where(x => x.Name, "SomeObjectName");
var fileFieldDto = new FileFieldDTO
{
Field = fileField,
ObjectRef = objectRef,
FileName = "Some File Name",
};
using (FileStream fileStream = File.OpenRead("C:\sample\path\to\SomeFile"))
{
fileFieldDto.FileStream = fileStream;
fileFieldDto = _sut.UploadFile(workspaceId, fileFieldDto);
}
Exceptions
Type | Condition |
---|---|
System.ArgumentException | The fileFieldDto does not contain all needed data. |