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:
@@ -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>());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user