DocumentClient.UpsertAttachmentAsync Método

Definición

Sobrecargas

UpsertAttachmentAsync(Uri, Object, RequestOptions, CancellationToken)

Upserts un archivo adjunto como una operación asincrónica en el servicio Azure Cosmos DB.

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

Upserts un archivo adjunto como una operación asincrónica en el servicio Azure Cosmos DB.

UpsertAttachmentAsync(String, Object, RequestOptions, CancellationToken)

Upserts un archivo adjunto como una operación asincrónica en el servicio Azure Cosmos DB.

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

Upserts un Attachment con el contenido de proporcionado mediaStream como una operación asincrónica en el servicio Azure Cosmos DB.

UpsertAttachmentAsync(Uri, Object, RequestOptions, CancellationToken)

Upserts un archivo adjunto como una operación asincrónica en el servicio 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>>
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

el URI del documento para el que se va a actualizar un archivo adjunto.

attachment
Object

el objeto attachment.

options
RequestOptions

Opciones de solicitud para la solicitud.

cancellationToken
CancellationToken

(Opcional) CancellationToken que representa la cancelación de la solicitud.

Devoluciones

Objeto de tarea que representa la respuesta del servicio para la operación asincrónica.

Implementaciones

Se aplica a

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

Upserts un archivo adjunto como una operación asincrónica en el servicio Azure Cosmos DB.

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

el URI del documento para el que se va a actualizar un archivo adjunto.

mediaStream
Stream

la secuencia del medio de datos adjuntos.

options
MediaOptions

las opciones multimedia de la solicitud.

requestOptions
RequestOptions

Opciones de solicitud para la solicitud.

cancellationToken
CancellationToken

(Opcional) CancellationToken que representa la cancelación de la solicitud.

Devoluciones

Objeto de tarea que representa la respuesta del servicio para la operación asincrónica.

Implementaciones

Se aplica a

UpsertAttachmentAsync(String, Object, RequestOptions, CancellationToken)

Upserts un archivo adjunto como una operación asincrónica en el servicio 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

Vínculo del documento primario para estos nuevos datos adjuntos. Por ejemplo, dbs/db_rid/colls/col_rid/docs/doc_rid/

attachment
Object

Objeto de datos adjuntos.

options
RequestOptions

(Opcional) Opciones de solicitud para la solicitud.

cancellationToken
CancellationToken

(Opcional) que CancellationToken pueden ser utilizados por otros objetos o subprocesos para recibir aviso de cancelación.

Devoluciones

Objeto Task que representa la respuesta del servicio para la operación asincrónica.

Implementaciones

Ejemplos

En el ejemplo siguiente se crea un nuevo documento y, a continuación, se crea un nuevo archivo adjunto para ese 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" });

Consulte también

Se aplica a

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

Upserts un Attachment con el contenido de proporcionado mediaStream como una operación asincrónica en el servicio 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

Vínculo de datos adjuntos para el documento. Por ejemplo, dbs/db_rid/colls/col_rid/docs/doc_rid/attachments/

mediaStream
Stream

del Stream medio de datos adjuntos.

options
MediaOptions

para MediaOptions la solicitud.

requestOptions
RequestOptions

para RequestOptions la solicitud.

cancellationToken
CancellationToken

(Opcional) que CancellationToken pueden ser utilizados por otros objetos o subprocesos para recibir aviso de cancelación.

Devoluciones

Objeto de tarea que representa la respuesta del servicio para la operación asincrónica.

Implementaciones

Excepciones

Si se establece o attachmentsLinkmediaStream no.

Ejemplos

//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"
                                        });
}

Consulte también

Se aplica a