Partager via


CloudBlockBlob.UploadFromFile Méthode

Définition

Charge un fichier dans le service Blob. Si l’objet blob existe déjà, il est remplacé.

[Microsoft.Azure.Storage.DoesServiceRequest]
public virtual void UploadFromFile (string path, Microsoft.Azure.Storage.AccessCondition accessCondition = default, Microsoft.Azure.Storage.Blob.BlobRequestOptions options = default, Microsoft.Azure.Storage.OperationContext operationContext = default);
[<Microsoft.Azure.Storage.DoesServiceRequest>]
abstract member UploadFromFile : string * Microsoft.Azure.Storage.AccessCondition * Microsoft.Azure.Storage.Blob.BlobRequestOptions * Microsoft.Azure.Storage.OperationContext -> unit
override this.UploadFromFile : string * Microsoft.Azure.Storage.AccessCondition * Microsoft.Azure.Storage.Blob.BlobRequestOptions * Microsoft.Azure.Storage.OperationContext -> unit
Public Overridable Sub UploadFromFile (path As String, Optional accessCondition As AccessCondition = Nothing, Optional options As BlobRequestOptions = Nothing, Optional operationContext As OperationContext = Nothing)

Paramètres

path
String

Chaîne contenant le chemin du fichier fournissant le contenu de l’objet blob.

accessCondition
AccessCondition

Objet AccessCondition qui représente la condition qui doit être remplie pour que la demande continue.

options
BlobRequestOptions

Objet BlobRequestOptions qui spécifie les options supplémentaires de la demande. Si la valeur est null, les options par défaut sont appliquées à la demande.

operationContext
OperationContext

Objet OperationContext qui représente le contexte de l'opération actuelle.

Implémente

Attributs

Exemples

// This is one common way of creating a CloudStorageAccount object. You can get 
// your Storage Account Name and Key from the Azure Portal.
StorageCredentials credentials = new StorageCredentials(accountName, accountKey);
CloudStorageAccount storageAccount = new CloudStorageAccount(credentials, useHttps: true);

// Another common way to create a CloudStorageAccount object is to use a connection string:
// CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);

CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

// This call creates a local CloudBlobContainer object, but does not make a network call
// to the Azure Storage Service. The container on the service that this object represents may
// or may not exist at this point. If it does exist, the properties will not yet have been
// popluated on this object.
CloudBlobContainer blobContainer = blobClient.GetContainerReference(containerName);

// This makes an actual service call to the Azure Storage service. Unless this call fails,
// the container will have been created.
blobContainer.Create();

// This also does not make a service call, it only creates a local object.
CloudBlockBlob blob = blobContainer.GetBlockBlobReference(blobName);

// This transfers data in the file to the blob on the service.
blob.UploadFromFile(inputFileName);

S’applique à