This document describes the how the FileOperationsWithStream
project implements the common operations described in Web API File Operations sample. See that document for an overview and how to run this sample.
The FileOperationsWithStream
project demonstrates how to upload or download files with a single request using Http methods and the Dataverse Web API.
Important This method can only be used to upload files less than 128 MB.
This sample uses classes defined within the WebAPIService project Messages folder so that they can be re-used. These classes inherit from the .NET HttpRequestMessage and HttpResponseMessage classes. These classes have constructors that accept the relevant variables to compose the requests to send, or to deserialize the responses into standard properties.
The code for this sample is in the Program.cs file.
To upload a PDF file named 25mb.pdf
to the sample_FileColumn
file column on the account record, this sample uses the UploadFileRequest class. This request doesn't have any response value to process.
If the file was succesfully uploaded, to download the text file named 25mb.pdf
that was just uploaded to the sample_FileColumn
file column on the account record, this sample uses the DownloadFileRequest class.
To process the response the DownloadFileResponse class simply reads the response content as a byte[] to get the entire file.
If the file was succesfully uploaded, use the DeleteColumnValueRequest class to delete the file.This method can be used to delete the value of any type of column. This request doesn't have any response value to process.