Partager via


DeviceUpdateClient.GetFile Méthode

Définition

Obtenez un fichier de mise à jour spécifique à partir de la 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

Paramètres

provider
String

Fournisseur de mise à jour.

name
String

Nom de la mise à jour.

version
String

Mettre à jour la version.

fileId
String

Identificateur de fichier.

ifNoneMatch
Nullable<ETag>

Définit la condition If-None-Match. L’opération est effectuée uniquement si l’ETag sur le serveur ne correspond pas à cette valeur.

context
RequestContext

Contexte de la demande, qui peut remplacer les comportements par défaut du pipeline client par appel.

Retours

Réponse retournée par le service. Les détails du schéma du corps de la réponse se trouvent dans la section Remarques ci-dessous.

Exceptions

provider, name, version ou fileId a la valeur Null.

provider, nameversion ou fileId est une chaîne vide, et était censé être non vide.

Le service a retourné un code de status non réussi.

Exemples

Cet exemple montre comment appeler GetFile avec les paramètres requis et analyser le résultat.

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());

Cet exemple montre comment appeler GetFile avec tous les paramètres et comment analyser le résultat.

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());

Remarques

Vous trouverez ci-dessous le schéma JSON pour la charge utile de réponse.

Corps de réponse :

Schéma pour 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).
            }

S’applique à