IDocumentClient.UpsertAttachmentAsync メソッド

定義

オーバーロード

UpsertAttachmentAsync(Uri, Object, RequestOptions, CancellationToken)

Azure Cosmos DB サービスの非同期操作として添付ファイルをアップサートします。

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

Azure Cosmos DB サービスの非同期操作として添付ファイルをアップサートします。

UpsertAttachmentAsync(String, Object, RequestOptions, CancellationToken)

Azure Cosmos DB サービスの非同期操作として添付ファイルをアップサートします。

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

Azure Cosmos DB サービスで非同期操作として提供される mediaStream の内容を使用して をアップサートAttachmentします。

UpsertAttachmentAsync(Uri, Object, RequestOptions, CancellationToken)

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

パラメーター

documentUri
Uri

添付ファイルをアップサートするドキュメントの URI。

attachment
Object

Attachment オブジェクト。

options
RequestOptions

(省略可能) RequestOptions 要求の 。

cancellationToken
CancellationToken

(省略可能) CancellationToken 取り消しの通知を受け取るために他のオブジェクトまたはスレッドが使用できる 。

戻り値

非同期操作のサービス応答を表すタスク オブジェクト。

適用対象

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

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

パラメーター

documentUri
Uri

添付ファイルをアップサートするドキュメントの URI。

mediaStream
Stream

添付ファイル メディアのストリーム。

options
MediaOptions

要求の MediaOptions

requestOptions
RequestOptions

要求の RequestOptions

cancellationToken
CancellationToken

(省略可能) CancellationToken 取り消しの通知を受け取るために他のオブジェクトまたはスレッドが使用できる 。

戻り値

非同期操作のサービス応答を表すタスク オブジェクト。

適用対象

UpsertAttachmentAsync(String, Object, RequestOptions, CancellationToken)

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

パラメーター

documentLink
String

この新しい添付ファイルの親ドキュメントのリンク。 例: dbs/db_rid/colls/col_rid/docs/doc_rid/

attachment
Object

添付ファイル オブジェクト。

options
RequestOptions

(省略可能)要求の要求オプション。

cancellationToken
CancellationToken

(省略可能) CancellationToken 取り消しの通知を受け取るために他のオブジェクトまたはスレッドが使用できる 。

戻り値

Task非同期操作のサービス応答を表す オブジェクト。

次の例では、新しいドキュメントを作成し、そのドキュメントの新しい添付ファイルをアップサートします

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

こちらもご覧ください

適用対象

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

Azure Cosmos DB サービスで非同期操作として提供される mediaStream の内容を使用して をアップサートAttachmentします。

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

パラメーター

attachmentsLink
String

ドキュメントの添付ファイル リンク。 例: dbs/db_rid/colls/col_rid/docs/doc_rid/attachments/

mediaStream
Stream

添付 Stream ファイル メディアの 。

options
MediaOptions

要求 MediaOptions の 。

requestOptions
RequestOptions

要求 RequestOptions の 。

cancellationToken
CancellationToken

(省略可能) CancellationToken 取り消しの通知を受け取るために他のオブジェクトまたはスレッドが使用できる 。

戻り値

非同期操作のサービス応答を表すタスク オブジェクト。

例外

または mediaStreamattachmentsLink設定されていない場合。

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

こちらもご覧ください

適用対象