Hi Adarsh,
Here's a minimal example on how to upload a file (in this case equation.png) using the dotnet SDK:
1) Start by creating a file resource in CDF
var fileDto = new FileCreate {
Name = "equation.png",
Source = "equation.png",
MimeType = "image/png",
ExternalId = "dotnet-sdk-test",
};
var fileCreate = await client.Files.UploadAsync(file: fileDto);
The fileCreate object will have an UploadUrl property which you can use to upload your file.
2) Use an HttpClient instance to upload the file (in this example, I’m using the same httpClient I used to instantiate the CogniteClient):
var fileBytes = System.IO.File.ReadAllBytes("equation.png");
var byteContent = new ByteArrayContent(fileBytes);
byteContent.Headers.ContentType = new MediaTypeHeaderValue(fileCreate.MimeType);
var response = await httpClient.PutAsync(fileCreate.UploadUrl, byteContent);
Ensure that the HTTP response status is successful to confirm that the file has been uploaded correctly.
3) Once your file is successfully uploaded, you can retrieve the file from CDF and check the Uploaded property. If it's set to True, that means the file has been successfully uploaded.
var res = await client.Files.RetrieveAsync(ids: new List<Identity>{ new Identity(fileCreate.Id) });
I hope this helps to clarify the process of uploading files with the dotnet SDK.