ビュー:

動作:
APIを使用して大きな文書をアップロードすると、次のエラーメッセージが表示されます。

"Exception 413 Request Entity Too Large"

解決方法:
.NET SDKまたはREST APIで大きなファイルをアップロードする方法については、次のガイドを参照してください;

.NET SDK
大きな文書をアップロードするには、DocuWareのDeveloperページにある以下の方法を使用すると、塊でアップロードすることができます。
Easy Uploading Huge Files | DocuWare SDK Documentation.

REST API
REST API経由で大きな文書をアップロードする場合は、異なるアプローチを取る必要があります。
この方法を達成する方法の例を参照してください;

using System.Net;
using RestSharp;
using System.IO;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;

public static class ChunkUpload {.

public static void RestSharpCallSequence()
{
string orgName = ""; // X.docuware.CloudのX。cloud
string userName = ""; //ログインするユーザ名
string password = "";// パスワード
string fileCabinetID = ""; //ファイルキャビネットID
string BaseUrl = "https://ORGNAME.docuware.com/DocuWare/Platform";
RestClient client = new RestClient(BaseUrl);

RestRequest request = new RestRequest($"{baseURL}/Account/Logon", Method.Post);

request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
request.AddHeader("Accept", "application/json");

request.AddParameter("Organization", orgName);
request.AddParameter("UserName", userName);
request.AddParameter("Password", password);
request.AddParameter("RememberMe", "true");

RestResponse response = client.Execute(request);
//次の呼び出しで使用するためにクッキーをキャプチャする
Cookie cookie = response.Cookies[1];

Console.WriteLine("Finished");
// チャンキング設定
chunkUpload(cookie, client);
}.

public static void chunkUpload(Cookie cookie, RestClient restClient)
{
// APIベースとファイルキャビネットのURLを定義する
RestClient client = restClient;
string OrgName = ""; // XのX。docuware.cloud
string baseURL = $"https://{OrgName}.docuware.cloud";
string platformURL = $"{baseURL}/DocuWare/Platform";
string FileCabinetId = "98f77e6e-5a56-406e-a6d4-51ef7a37eda1";

//
int ChunkSize = 10 * 1024 * 1024; // 10 MB

// アップロードするファイルのパスを設定する
string filePath = $""; //ファイルパスに変更する必要があります|

try
{
//ファイルストリームを開き、ファイルサイズ、ファイル名、更新日時を取得する。
FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read);
long totalFileSize = fileStream.Length;
string fileName = Path.GetFileName(filePath);
DateTime modificationDate = File.GetLastWriteTimeUtc(filePath);

// エンドポイントURLを設定し、POSTメソッドで新しいRestRequestオブジェクトを作成する
string suffix = $"/FileCabinets/{FileCabinetId}/Documents/";
string url = $"{platformURL}/{suffix}";
var request = new RestRequest(url, Method.Post);

// チャンクアップロード用の変数を初期化する
string chunkReference = null;
int bytesUploaded = 0;

// ファイルをループし、チャンクをアップロードする
while (bytesUploaded < totalFileSize)
{
// ファイルのチャンクをバッファに読み込む
byte[] buffer = new byte[ChunkSize];
int bytesRead = fileStream.Read(buffer, 0, ChunkSize);

// 最後のチャンクがチャンクサイズより小さい場合、バッファのサイズを変更する
if (bytesRead < ChunkSize)
{
Array.Resize(ref buffer, bytesRead);
}.

// リクエストのヘッダーを設定する
request.AddHeader("Content-Type", "application/octet-stream");
request.AddHeader("Content-Length", bytesRead.ToString());
request.AddHeader("Content-Disposition", $"inline; filename="{fileName}"; modificationdate="{modificationDate:R}");
request.AddHeader("X-File-ModifiedDate", $"{modificationDate:R}");
request.AddHeader("X-File-Name", fileName);
request.AddHeader("X-File-Size", totalFileSize.ToString());
request.AddHeader("Cookie", cookie.ToString());
request.AddHeader("Expect", "100-continue");

// チャンクデータをリクエストボディに追加する
request.AddParameter("application.AddParameter("application/octet-stream", buffer, ParameterType.RequestBody);

// これが最初のチャンクでない場合、チャンク参照とロケーションヘッダをリクエストに追加する
if (!string.IsNullOrEmpty(chunkReference))
{
request.AddQueryParameter("loc", bytesUploaded.ToString());
request.AddQueryParameter("chunkReference", chunkReference);
}.

// ベースURLを設定し、クッキーをクライアントに追加する
Uri baseUri = new Uri(platformURL);
client.CookieContainer.Add(cookie);


// チャンクアップロードリクエストを実行する
var response = client.Execute(request);
var deserializedJsonResponseBody = JsonConvert.DeserializeObject<IntermediateResponse>(response.Content.ToString());

// レスポンスのステータス・コードをチェックする
if (response.StatusCode != HttpStatusCode.OK)
{
Console.WriteLine($"Unexpected status code: {response.StatusCode}");
Console.WriteLine("エラー: アップロードに失敗しました。");
return;
}.

Console.WriteLine("Chunk Request Executed");


/* アップロードするチャンクがまだある場合は、レスポンスから次のURLを取得します。* 次のチャンクのPOSTメソッドで新しいRestRequestオブジェクトを作成する
*/
if (bytesUploaded + bytesRead < totalFileSize)
{
// レスポンスJSONをデシリアライズして、次のURLを取得する。

url = baseURL + deserializedJsonResponseBody.FileChunk.Links[0].href;
request = new RestRequest(url, Method.Post);
}
else //最後のチャンクについて、最終的なデシリアライズされたレスポンスを取得する
{
var finalResposne = JsonConvert.DeserializeObject<JSON>(response.Content.ToString());
}
// アップロードされた合計バイト数を更新し、進捗を表示する
bytesUploaded += bytesRead;

Console.WriteLine($"Uploaded {bytesUploaded} / {ttotalFileSize} bytes");
}.

Console.WriteLine("File uploaded successfully.");
}
catch (Exception e)
{
Console.WriteLine(e);
}.


}

/*以下のクラスは、JSON文字列レスポンスの完全なデシリアライズのためのものです。
* この中で使用されるのは、RootObject->FileChunk->Link->href[0]で、これは "next "リンクを取得します。
*/
public class FileChunk
{
public List<Link> Links { get; set; }
public bool Finished { get; set; }
public string LastChunkId { get; set; }
public int BytesWritten { get; set; }
}.

public class Link
{
public string rel { get; set; }
public string href { get; set; }
}.

public class IntermediateResponse
{
public FileChunk FileChunk { get; set; }
public bool HaveMoreTotalPages { get; set; }
public bool HasTextAnnotation { get; set; }
public bool HasXmlDigitalSignatures { get; set; }
public bool AnnotationsPreview { get; set; }
public int TotalPages { get; set;}
public int Id { get; set; }
public bool LastModifiedSpecified { get;set; }
public bool CreatedAtSpecified { get; set; }
public int FileSize { get; set; }
public int SectionCount { get; set; }
public string IntellixTrust { get; set; }
public string VersionStatus { get; set; }
}.

public class Section
{
public List<string> SignatureStatus { get; set; }
public Pages Pages { get; set; }
public Thumbnails サムネイル { get; set; }
public List<Link> Links { get; set; }
public string Id { get; set; }
public string ContentType { get; set; }
public bool HaveMorePages { get; set; }
public int PageCount { get; set; }
public int FileSize { get; set; }
public string OriginalFileName { get;set; }
public string ContentModified { get; set; }
public bool HasTextAnnotation { get; set; }
public bool AnnotationsPreview { get; set; }
}.

public class Pages
{
public List<object> Page { get; set; }
}.

public class Thumbnails
{
public List<object> Page { get; set; }
}.

public class JSON
{
public Guid FileCabinetId { get; set; }
public List<Field> Fields { get; set; }
public Flags Flags { get; set; }
public Version Version { get; set; }
public List<Link> Links { get; set; }
public List<Section> Sections { get; set; }
public string ContentType { get; set; }
public FileChunk FileChunk { get; set; }
public bool HaveMoreTotalPages { get; set; }
public bool HasTextAnnotation { get; set; }
public bool HasXmlDigitalSignatures { get; set;}
public bool AnnotationsPreview { get; set; }
public int TotalPages { get; set; }
public int Id { get; set; }
public string Title { get; set; }
public string LastModified { get; set; }
public bool LastModifiedSpecified { get; set; }
public string CreatedAt { get; set; }
public bool CreatedAtSpecified { get; set; }
public int FileSize { get; set; }
public int SectionCount { get; set; }
public string IntellixTrust { get; set; }
public string VersionStatus { get; set; }
}.

public class Field
{
public bool SystemField { get; set; }
public string FieldName { get; set; }
public string FieldLabel { get; set; }
public bool IsNull { get; set; }
public bool ReadOnly { get; set; }
public object Item { get; set; }
public string ItemElementName { get; set; }
}.

public class Flags
{
public bool IsCold { get; set; }
public bool IsDBRecord { get;set; }
public bool IsCheckedOut { get; set; }
public bool IsCopyRightProtected { get; set; }
public bool IsVoiceAvailable { get; set; }
public bool HasAppendedDocuments { get; set; }
public bool IsProtected { get; set; }
public bool IsDeleted { get; set; }
public bool IsEmail { get; set; }
}
} クラウド・オンデマンドに適用されるKBA。

クラウド 組織と オンプレミス組織の両方に適用可能なKBA

注意:この記事英語からの翻訳ですこの記事まれる情報オリジナルの英語版製品づくものです。翻訳版記事使用されている文法などには、細かいりがある場合があります。翻訳正確さを完全保証することは出来かねますがほとんどの場合、十分情報られるとわれます。万一、疑問じた場合、英語版記事えてごください