Udostępnij za pośrednictwem


DeviceUpdateClient.GetFileAsync Method

Definition

Get a specific update file from the version.

public virtual System.Threading.Tasks.Task<Azure.Response> GetFileAsync (string provider, string name, string version, string fileId, Azure.ETag? ifNoneMatch = default, Azure.RequestContext context = default);
abstract member GetFileAsync : string * string * string * string * Nullable<Azure.ETag> * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
override this.GetFileAsync : string * string * string * string * Nullable<Azure.ETag> * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
Public Overridable Function GetFileAsync (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 Task(Of Response)

Parameters

provider
String

Update provider.

name
String

Update name.

version
String

Update version.

fileId
String

File identifier.

ifNoneMatch
Nullable<ETag>

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 GetFileAsync 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 = await client.GetFileAsync("<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 GetFileAsync 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 = await client.GetFileAsync("<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