You can also use File Field Manager service through REST. However, this service doesn't support cancellation tokens or progress indicators through REST. For more information, see File Field Manager (REST).
This page contains the following information:
The Relativity.Services.FileField namespace contains the IFileFieldManager interface, which exposes the following methods:
Note: Use an object of type System.IProgress or System.Threading.CancellationToken provided by the .NET framework for progress and cancellation functionality respectively.
The sample workflow outlines how you might use the Object Manager API in conjunction to the File Field Manager API to add files to Relativity:
After you upload a file to Relativity via the File Field Manager API, it is added to temporary storage on the server until the RDO with the File field is saved. If the RDO with the File field and associated file aren’t saved, the server deletes it after about twenty-four hours.
To download a file from a file field, pass the following arguments to the DownloadAsync() method:
Note: Set the {workspaceId} to -1 to indicate the admin-level context.
The DownloadAsync() method returns the content of the file as a stream.
public async Task<bool> DownloadAsync(IHelper helper) { var objectArtifactId = this.SampleRDO_ID; var fieldArtifactId = this.SampleField_File_ID; var workspaceID = this.SampleWorkspace_ID; var relativityObject = new RelativityObjectRef { ArtifactID = objectArtifactId }; var field = new FieldRef() { ArtifactID = fieldArtifactId }; bool success = false; using (IFileFieldManager proxy = helper.GetServicesManager().CreateProxy<IFileFieldManager>(ExecutionIdentity.User)) { Logging.ISampleLogger logger = _logger.ForContext("MethodName", nameof(DownloadAsync), false); try { IKeplerStream stream = await proxy.DownloadAsync(workspaceID, relativityObject, field); Stream file = stream.GetStreamAsync().Result; success = stream.GetStreamAsync().Status == TaskStatus.RanToCompletion; } catch (Exception ex) { logger.LogError(ex, "Unhandled Exception"); } } return success; }
To upload a file to a file field, pass the following arguments to the UploadAsync() method:
Note: Set the {workspaceId} to -1 to indicate the admin-level context.
The UploadAsync() method returns a FieldRef object.
public async Task<bool> UploadAsync(IHelper helper) { var success = false; var objectArtifactId = this.SampleRDO_ID; var fieldArtifactId = this.SampleField_File_ID; var workspaceID = this.SampleWorkspace_ID; var fileName = "LoremIpsum.docx"; var relativityObject = new RelativityObjectRef { ArtifactID = objectArtifactId }; var field = new FieldRef() { ArtifactID = fieldArtifactId, Name = fileName }; var filePath = string.Format("{0}\\SampleFiles\\{1}", Directory.GetCurrentDirectory(), fileName); using (IFileFieldManager proxy = helper.GetServicesManager().CreateProxy<IFileFieldManager>(ExecutionIdentity.User)) { Logging.ISampleLogger logger = _logger.ForContext("MethodName", nameof(DownloadAsync), false); try { var keplerStream = new KeplerStream(File.OpenRead(filePath)); var uploadedFile = await proxy.UploadAsync(workspaceID, field, relativityObject, fileName, keplerStream); success = uploadedFile?.UploadedFileGuid != null; } catch (Exception ex) { logger.LogError(ex, "Unhandled Exception"); } } return success; }
Community Updates |
|||
Aero Developer FAQ | Evolving the Platform | Most recent release notes | |
Learn more | Learn more | Learn more |
Additional Resources |
|||
![]() |
![]() |
||
Access Third-Party Tools with GitHub | Create .NET Apps Faster with NuGet | ||
Visit github | visit nuget |