DeviceUpdateClient.GetFile Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Get a specific update file from the version.
public virtual Azure.Response GetFile (string provider, string name, string version, string fileId, Azure.ETag? ifNoneMatch = default, Azure.RequestContext context = default);
abstract member GetFile : string * string * string * string * Nullable<Azure.ETag> * Azure.RequestContext -> Azure.Response
override this.GetFile : string * string * string * string * Nullable<Azure.ETag> * Azure.RequestContext -> Azure.Response
Public Overridable Function GetFile (provider As String, name As String, version As String, fileId As String, Optional ifNoneMatch As Nullable(Of ETag) = Nothing, Optional context As RequestContext = Nothing) As Response
Parameters
- provider
- String
Update provider.
- name
- String
Update name.
- version
- String
Update version.
- fileId
- String
File identifier.
Defines the If-None-Match condition. The operation will be performed only if the ETag on the server does not match this value.
- context
- RequestContext
The request context, which can override default behaviors of the client pipeline on a per-call basis.
Returns
The response returned from the service. Details of the response body schema are in the Remarks section below.
Exceptions
provider
, name
, version
or fileId
is null.
provider
, name
, version
or fileId
is an empty string, and was expected to be non-empty.
Service returned a non-success status code.
Examples
This sample shows how to call GetFile with required parameters and parse the result.
var credential = new DefaultAzureCredential();
var endpoint = new Uri("<https://my-service.azure.com>");
var client = new DeviceUpdateClient(endpoint, "<instanceId>", credential);
Response response = client.GetFile("<provider>", "<name>", "<version>", "<fileId>");
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("fileId").ToString());
Console.WriteLine(result.GetProperty("fileName").ToString());
Console.WriteLine(result.GetProperty("sizeInBytes").ToString());
Console.WriteLine(result.GetProperty("hashes").GetProperty("<test>").ToString());
This sample shows how to call GetFile with all parameters, and how to parse the result.
var credential = new DefaultAzureCredential();
var endpoint = new Uri("<https://my-service.azure.com>");
var client = new DeviceUpdateClient(endpoint, "<instanceId>", credential);
Response response = client.GetFile("<provider>", "<name>", "<version>", "<fileId>", null);
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("fileId").ToString());
Console.WriteLine(result.GetProperty("relatedFiles")[0].GetProperty("fileName").ToString());
Console.WriteLine(result.GetProperty("relatedFiles")[0].GetProperty("sizeInBytes").ToString());
Console.WriteLine(result.GetProperty("relatedFiles")[0].GetProperty("hashes").GetProperty("<test>").ToString());
Console.WriteLine(result.GetProperty("relatedFiles")[0].GetProperty("mimeType").ToString());
Console.WriteLine(result.GetProperty("relatedFiles")[0].GetProperty("scanResult").ToString());
Console.WriteLine(result.GetProperty("relatedFiles")[0].GetProperty("scanDetails").ToString());
Console.WriteLine(result.GetProperty("relatedFiles")[0].GetProperty("properties").GetProperty("<test>").ToString());
Console.WriteLine(result.GetProperty("downloadHandler").GetProperty("id").ToString());
Console.WriteLine(result.GetProperty("etag").ToString());
Console.WriteLine(result.GetProperty("fileName").ToString());
Console.WriteLine(result.GetProperty("sizeInBytes").ToString());
Console.WriteLine(result.GetProperty("hashes").GetProperty("<test>").ToString());
Console.WriteLine(result.GetProperty("mimeType").ToString());
Console.WriteLine(result.GetProperty("scanResult").ToString());
Console.WriteLine(result.GetProperty("scanDetails").ToString());
Console.WriteLine(result.GetProperty("properties").GetProperty("<test>").ToString());
Remarks
Below is the JSON schema for the response payload.
Response Body:
Schema for UpdateFile
:
{
fileId: string, # Required. File identity, generated by server at import time.
relatedFiles: [
{
fileName: string, # Required. File name.
sizeInBytes: number, # Required. File size in number of bytes.
hashes: Dictionary<string, string>, # Required. Mapping of hashing algorithm to base64 encoded hash values.
mimeType: string, # Optional. File MIME type.
scanResult: string, # Optional. Anti-malware scan result.
scanDetails: string, # Optional. Anti-malware scan details.
properties: Dictionary<string, string>, # Optional. Optional file properties (not consumed by service but pass-through to device).
}
], # Optional. Optional related files metadata used together DownloadHandler metadata to download payload file.
downloadHandler: {
id: string, # Required. Download handler identifier.
}, # Optional. Optional download handler for utilizing related files to download payload file.
etag: string, # Optional. File ETag.
fileName: string, # Required. File name.
sizeInBytes: number, # Required. File size in number of bytes.
hashes: Dictionary<string, string>, # Required. Mapping of hashing algorithm to base64 encoded hash values.
mimeType: string, # Optional. File MIME type.
scanResult: string, # Optional. Anti-malware scan result.
scanDetails: string, # Optional. Anti-malware scan details.
properties: Dictionary<string, string>, # Optional. Optional file properties (not consumed by service but pass-through to device).
}
Applies to
Azure SDK for .NET