Partilhar via


DocumentClient.UpsertAttachmentAsync Método

Definição

Sobrecargas

UpsertAttachmentAsync(Uri, Object, RequestOptions, CancellationToken)

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

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

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

UpsertAttachmentAsync(String, Object, RequestOptions, CancellationToken)

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

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

Aumenta um Attachment com o conteúdo do fornecido mediaStream como uma operação assíncrona no serviço do Azure Cosmos DB.

UpsertAttachmentAsync(Uri, Object, 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, 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>>
override this.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 de anexo.

options
RequestOptions

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

cancellationToken
CancellationToken

(Opcional) CancellationToken que representa o cancelamento da solicitação.

Retornos

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

Implementações

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>>
override this.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

as opções de mídia para a solicitação.

requestOptions
RequestOptions

Opções de solicitação para a solicitação.

cancellationToken
CancellationToken

(Opcional) CancellationToken que representa o cancelamento da solicitação.

Retornos

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

Implementações

Aplica-se a

UpsertAttachmentAsync(String, Object, RequestOptions, CancellationToken)

Faz upserts de 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>>
override this.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 de anexo.

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 uma notificação de cancelamento.

Retornos

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

Implementações

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)

Aumenta um Attachment com o conteúdo do fornecido mediaStream 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 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>>
override this.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 uma notificação de cancelamento.

Retornos

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

Implementações

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