Partilhar via


IDocumentClient.UpsertAttachmentAsync Método

Definição

Sobrecargas

UpsertAttachmentAsync(Uri, Object, RequestOptions, CancellationToken)

Aumenta um anexo como uma operação assíncrona no serviço do Azure Cosmos DB.

UpsertAttachmentAsync(Uri, Stream, MediaOptions, RequestOptions, CancellationToken)

Upserts an attachment as an asynchronous operation in the Azure Cosmos DB service.

UpsertAttachmentAsync(String, Object, RequestOptions, CancellationToken)

Aumenta um anexo como uma operação assíncrona no serviço do Azure Cosmos DB.

UpsertAttachmentAsync(String, Stream, MediaOptions, RequestOptions, CancellationToken)

Upserts an Attachment with the contents of the provided mediaStream asynchronous operation in the Azure Cosmos DB service.

UpsertAttachmentAsync(Uri, Object, RequestOptions, CancellationToken)

Aumenta um anexo como uma operação assíncrona no serviço do Azure Cosmos DB.

public System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.Attachment>> UpsertAttachmentAsync (Uri documentUri, object attachment, Microsoft.Azure.Documents.Client.RequestOptions options = default, System.Threading.CancellationToken cancellationToken = default);
abstract member UpsertAttachmentAsync : Uri * obj * Microsoft.Azure.Documents.Client.RequestOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.Attachment>>
Public Function UpsertAttachmentAsync (documentUri As Uri, attachment As Object, Optional options As RequestOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of ResourceResponse(Of Attachment))

Parâmetros

documentUri
Uri

O URI do documento para o qual inserir um anexo.

attachment
Object

O objeto Attachment.

options
RequestOptions

(Opcional) O RequestOptions para a solicitação.

cancellationToken
CancellationToken

(Opcional) Um CancellationToken que pode ser usado por outros objetos ou threads para receber notificação de cancelamento.

Retornos

O objeto de tarefa que representa a resposta de serviço para a operação assíncrona.

Aplica-se a

UpsertAttachmentAsync(Uri, Stream, MediaOptions, RequestOptions, CancellationToken)

Upserts an attachment as an asynchronous operation in the Azure Cosmos DB service.

public System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.Attachment>> UpsertAttachmentAsync (Uri documentUri, System.IO.Stream mediaStream, Microsoft.Azure.Documents.Client.MediaOptions options = default, Microsoft.Azure.Documents.Client.RequestOptions requestOptions = default, System.Threading.CancellationToken cancellationToken = default);
abstract member UpsertAttachmentAsync : Uri * System.IO.Stream * Microsoft.Azure.Documents.Client.MediaOptions * Microsoft.Azure.Documents.Client.RequestOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.Attachment>>
Public Function UpsertAttachmentAsync (documentUri As Uri, mediaStream As Stream, Optional options As MediaOptions = Nothing, Optional requestOptions As RequestOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of ResourceResponse(Of Attachment))

Parâmetros

documentUri
Uri

O URI do documento para o qual inserir um anexo.

mediaStream
Stream

O fluxo da mídia de anexo.

options
MediaOptions

O MediaOptions para a solicitação.

requestOptions
RequestOptions

O RequestOptions para a solicitação.

cancellationToken
CancellationToken

(Opcional) Um CancellationToken que pode ser usado por outros objetos ou threads para receber notificação de cancelamento.

Retornos

O objeto de tarefa que representa a resposta de serviço para a operação assíncrona.

Aplica-se a

UpsertAttachmentAsync(String, Object, RequestOptions, CancellationToken)

Aumenta um anexo como uma operação assíncrona no serviço do Azure Cosmos DB.

public System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.Attachment>> UpsertAttachmentAsync (string documentLink, object attachment, Microsoft.Azure.Documents.Client.RequestOptions options = default, System.Threading.CancellationToken cancellationToken = default);
abstract member UpsertAttachmentAsync : string * obj * Microsoft.Azure.Documents.Client.RequestOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.Attachment>>
Public Function UpsertAttachmentAsync (documentLink As String, attachment As Object, Optional options As RequestOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of ResourceResponse(Of Attachment))

Parâmetros

documentLink
String

O link do documento pai para este novo anexo. Por exemplo, dbs/db_rid/colls/col_rid/docs/doc_rid/

attachment
Object

O objeto attachment.

options
RequestOptions

(Opcional) As opções de solicitação para a solicitação.

cancellationToken
CancellationToken

(Opcional) Um CancellationToken que pode ser usado por outros objetos ou threads para receber notificação de cancelamento.

Retornos

O Task objeto que representa a resposta de serviço para a operação assíncrona.

Exemplos

O exemplo a seguir cria um novo documento e, em seguida, cria um novo anexo para esse documento

dynamic d = new
{
    id = "DOC1800243243470"
};

Document doc = await client.CreateDocumentAsync(collectionSelfLink, d);

//Upsert an Attachment which links to binary content stored somewhere else
//Use the MediaLink property of Attachment to set where the binary resides
//MediaLink can also point at another Attachment within Azure Cosmos DB.
Attachment a = await client.UpsertAttachmentAsync(doc.SelfLink, new Attachment { Id = "foo", ContentType = "text/plain", MediaLink = "link to your media" });

Confira também

Aplica-se a

UpsertAttachmentAsync(String, Stream, MediaOptions, RequestOptions, CancellationToken)

Upserts an Attachment with the contents of the provided mediaStream asynchronous operation in the Azure Cosmos DB service.

public System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.Attachment>> UpsertAttachmentAsync (string attachmentsLink, System.IO.Stream mediaStream, Microsoft.Azure.Documents.Client.MediaOptions options = default, Microsoft.Azure.Documents.Client.RequestOptions requestOptions = default, System.Threading.CancellationToken cancellationToken = default);
abstract member UpsertAttachmentAsync : string * System.IO.Stream * Microsoft.Azure.Documents.Client.MediaOptions * Microsoft.Azure.Documents.Client.RequestOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.Attachment>>
Public Function UpsertAttachmentAsync (attachmentsLink As String, mediaStream As Stream, Optional options As MediaOptions = Nothing, Optional requestOptions As RequestOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of ResourceResponse(Of Attachment))

Parâmetros

attachmentsLink
String

O link de anexos para o documento. Por exemplo, dbs/db_rid/colls/col_rid/docs/doc_rid/attachments/

mediaStream
Stream

o Stream da mídia de anexo.

options
MediaOptions

o MediaOptions para a solicitação.

requestOptions
RequestOptions

o RequestOptions para a solicitação.

cancellationToken
CancellationToken

(Opcional) Um CancellationToken que pode ser usado por outros objetos ou threads para receber notificação de cancelamento.

Retornos

O objeto de tarefa que representa a resposta de serviço para a operação assíncrona.

Exceções

Se ou attachmentsLinkmediaStream não estiver definido.

Exemplos

//This attachment could be any binary you want to attach. Like images, videos, word documents, pdfs etc. it doesn't matter
using (FileStream fileStream = new FileStream(@".\something.pdf", FileMode.Open))
{
    //Upsert the attachment
    Attachment attachment = await client.UpsertAttachmentAsync("dbs/db_rid/colls/coll_rid/docs/doc_rid/attachments/",
                                        fileStream,
                                        new MediaOptions
                                        {
                                            ContentType = "application/pdf",
                                            Slug = "something.pdf"
                                        });
}

Confira também

Aplica-se a