feat: Methode "Upload" zur Dateiübertragung mit Abfrageparametern hinzugefügt

- Methode "Upload" für das Hochladen von Dateien hinzugefügt.
- Unterstützung für Abfrageparameter wie item_id, item_location, item_name, flags und stream_identity hinzugefügt.
- Methode auf MultipartFormDataContent für die Dateiverarbeitung aktualisiert.
This commit is contained in:
Developer 02
2024-09-13 01:28:16 +02:00
parent e8cffa5fa0
commit d0ae6c4541
11 changed files with 59 additions and 24 deletions

View File

@@ -1,4 +1,4 @@
namespace WindreamHub.Legacy.Client.Models.Documents.Create.Response
namespace WindreamHub.Legacy.Client.Models.Documents.Response
{
public class Attribute
{

View File

@@ -1,8 +1,8 @@
using System.Collections.Generic;
namespace WindreamHub.Legacy.Client.Models.Documents.Create.Response
namespace WindreamHub.Legacy.Client.Models.Documents.Response
{
public class DocCreateResponse
public class DocResponse
{
public Item Item { get; set; }
public IndexingDetails IndexingDetails { get; set; }

View File

@@ -1,6 +1,6 @@
using WindreamHub.Legacy.Client.Models.Shared;
namespace WindreamHub.Legacy.Client.Models.Documents.Create.Response
namespace WindreamHub.Legacy.Client.Models.Documents.Response
{
public class Error
{

View File

@@ -1,4 +1,4 @@
namespace WindreamHub.Legacy.Client.Models.Documents.Create.Response
namespace WindreamHub.Legacy.Client.Models.Documents.Response
{
public class IndexingDetails
{

View File

@@ -1,6 +1,6 @@
using System.Collections.Generic;
namespace WindreamHub.Legacy.Client.Models.Documents.Create.Response
namespace WindreamHub.Legacy.Client.Models.Documents.Response
{
public class Item
{

View File

@@ -1,4 +1,4 @@
namespace WindreamHub.Legacy.Client.Models.Documents.Create.Response
namespace WindreamHub.Legacy.Client.Models.Documents.Response
{
public class ObjectType
{

View File

@@ -1,4 +1,4 @@
namespace WindreamHub.Legacy.Client.Models.Documents.Create.Response
namespace WindreamHub.Legacy.Client.Models.Documents.Response
{
public class ParentWindreamObject
{

View File

@@ -1,4 +1,4 @@
namespace WindreamHub.Legacy.Client.Models.Documents.Create.Response
namespace WindreamHub.Legacy.Client.Models.Documents.Response
{
public class TypeSpecificDetails
{

View File

@@ -1,4 +1,4 @@
namespace WindreamHub.Legacy.Client.Models.Documents.Create.Response
namespace WindreamHub.Legacy.Client.Models.Documents.Response
{
public class VectorDetails
{

View File

@@ -4,8 +4,10 @@ using System.Net.Http;
using DigitalData.Core.Legacy.Client;
using System.Threading.Tasks;
using WindreamHub.Legacy.Client.Models;
using WindreamHub.Legacy.Client.Models.Documents.Create.Response;
using WindreamHub.Legacy.Client.Models.Documents.Response;
using WindreamHub.Legacy.Client.Models.Documents.Create.Request;
using System.IO;
using System.Web;
namespace WindreamHub.Legacy.Client.Routes
{
@@ -15,12 +17,44 @@ namespace WindreamHub.Legacy.Client.Routes
{
}
public async Task<SimplifiedResponse<DocCreateResponse, object>> Create(HttpContent docCreateBody)
public async Task<SimplifiedResponse<DocResponse, object>> Create(HttpContent docCreateBody)
=> await FetchAsync(route: "/Create", method: HttpMethod.Post, body: docCreateBody)
.ThenAsync(res => res.Simplify<DocCreateResponse, object>());
.ThenAsync(res => res.Simplify<DocResponse, object>());
public async Task<SimplifiedResponse<DocCreateResponse, object>> Create(DocCreateBody docCreateBody)
public async Task<SimplifiedResponse<DocResponse, object>> Create(DocCreateBody docCreateBody)
=> await FetchAsync(route: "/Create", method: HttpMethod.Post, body: docCreateBody.Stringify())
.ThenAsync(res => res.Simplify<DocCreateResponse, object>());
.ThenAsync(res => res.Simplify<DocResponse, object>());
public async Task<SimplifiedResponse<DocResponse, object>> Upload(string path, long? item_id = null, string item_location = null, string item_name = null, object stream_identity = null, params int[] flags)
{
using (var fileStream = File.OpenRead(path))
{
var fileContent = new StreamContent(fileStream);
var formData = new MultipartFormDataContent
{
{ fileContent, "file", "filename.pdf" }
};
var query = HttpUtility.ParseQueryString(string.Empty);
if (item_id != null)
query["parameter.item.id"] = item_id.ToString();
if (item_location != null)
query["parameter.item.location"] = item_location;
if (item_name != null)
query["parameter.item.name"] = item_name;
if (flags != null && flags.Length > 0)
query["parameter.flags"] = string.Join(",", flags);
if (stream_identity != null)
query["parameter.stream.__identity"] = stream_identity.ToString();
return await FetchAsync(route: "/Upload", method: HttpMethod.Post, body: fileContent)
.ThenAsync(res => res.Simplify<DocResponse, object>());
}
}
}
}

View File

@@ -74,6 +74,7 @@
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\..\packages\System.ValueTuple.4.5.0\lib\net461\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Web" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
@@ -84,7 +85,7 @@
<ItemGroup>
<Compile Include="DIExtensions.cs" />
<Compile Include="Models\Authentication\ErrorDetails.cs" />
<Compile Include="Models\Documents\Create\Response\Error.cs" />
<Compile Include="Models\Documents\Response\Error.cs" />
<Compile Include="Models\Shared\ErrorItem.cs" />
<Compile Include="Models\Authentication\ICredential.cs" />
<Compile Include="Models\Authentication\ValidationResponse.cs" />
@@ -93,14 +94,14 @@
<Compile Include="Models\Documents\Create\Request\Item.cs" />
<Compile Include="Models\Documents\Create\Request\ObjectType.cs" />
<Compile Include="Models\Documents\Create\Request\DocCreateBody.cs" />
<Compile Include="Models\Documents\Create\Response\Attribute.cs" />
<Compile Include="Models\Documents\Create\Response\DocCreateResponse.cs" />
<Compile Include="Models\Documents\Create\Response\IndexingDetails.cs" />
<Compile Include="Models\Documents\Create\Response\Item.cs" />
<Compile Include="Models\Documents\Create\Response\ObjectType.cs" />
<Compile Include="Models\Documents\Create\Response\ParentWindreamObject.cs" />
<Compile Include="Models\Documents\Create\Response\TypeSpecificDetails.cs" />
<Compile Include="Models\Documents\Create\Response\VectorDetails.cs" />
<Compile Include="Models\Documents\Response\Attribute.cs" />
<Compile Include="Models\Documents\Response\DocResponse.cs" />
<Compile Include="Models\Documents\Response\IndexingDetails.cs" />
<Compile Include="Models\Documents\Response\Item.cs" />
<Compile Include="Models\Documents\Response\ObjectType.cs" />
<Compile Include="Models\Documents\Response\ParentWindreamObject.cs" />
<Compile Include="Models\Documents\Response\TypeSpecificDetails.cs" />
<Compile Include="Models\Documents\Response\VectorDetails.cs" />
<Compile Include="Models\ModelExtensions.cs" />
<Compile Include="Models\SimplifiedResponse.cs" />
<Compile Include="Models\SystemDetails\SystemDetails.cs" />