October3d55/M/HTTPWebCommunication/Source/WebCommunication/Public/UAsyncNodeHttpDownloadUpload.h

104 lines
6.9 KiB
C++

// Copyright 2017 David Romanski(Socke). All Rights Reserved.
#pragma once
#include "WebCommunication.h"
#include "UAsyncNodeWebCom.h"
#include "UAsyncNodeHttpDownloadUpload.generated.h"
DECLARE_DYNAMIC_MULTICAST_DELEGATE_FiveParams(FAsyncNodeHttpDownloadUploadCompleteDelegate, const FString, dataString, const TArray<FString>&, dataArray, const TArray<FString>&, header, const int32, statusCode, const FString, requestID);
UCLASS()
class WEBCOMMUNICATION_API UAsyncNodeHttpDownloadUpload : public UAsyncNodeWebCom
{
GENERATED_BODY()
public:
UPROPERTY(BlueprintAssignable)
FAsyncNodeHttpDownloadUploadCompleteDelegate OnSuccess;
UPROPERTY(BlueprintAssignable)
FAsyncNodeHttpDownloadUploadCompleteDelegate OnFail;
UFUNCTION(BlueprintCallable, Category = "WebCommunication|Download", meta = (BlueprintInternalUseOnly = "true", AutoCreateRefTerm = "header"))
static UAsyncNodeHttpDownloadUpload* AsyncExecuteHTTP_Download_REQUEST(FString url, TMap<FString, FString> header, EHTTPWebComFileDownloadResumeType ActionIfFileExists, EHTTPWebComFileUpload DirectoryType, FString filePathWithFileName, FString optionalRequestID);
/**
* For downloads. The file is downloaded in steps. This significantly reduces RAM consumption. The web server must support resuming aborted downloads.
* @param ActionIfFileExists Overwrite = overwrites an existing file otherwise a new one will be created. Cancel Download = If the file already exists, the download will be aborted. Resume = Download continues. If the file is missing, the download is started from the beginning.
* @param FileSizeStepsInBytes Default = 10 megabytes. Steps in which the download is aborted and restarted. Specified in bytes. You can use the node "MegabyteToByte" for conversion.
*/
UFUNCTION(BlueprintCallable, Category = "WebCommunication|Download", meta = (BlueprintInternalUseOnly = "true", AutoCreateRefTerm = "header"))
static UAsyncNodeHttpDownloadUpload* AsyncExecuteHTTP_Low_RAM_Download_REQUEST(FString url, TMap<FString, FString> header, EHTTPWebComFileDownloadResumeType ActionIfFileExists, EHTTPWebComFileUpload DirectoryType, FString filePathWithFileName, FString optionalRequestID, int32 FileSizeStepsInBytes = 10485760);
/**
* Send a file to a Webserver.
*
* @param url Server URL
* @param DirectoryType Absolute or Relative
* @param filePath File with path
* @param fileID name equivalent to <input type="file" name="myFile"> from an html upload
*/
UFUNCTION(BlueprintCallable, Category = "WebCommunication|File Upload", meta = (BlueprintInternalUseOnly = "true", AutoCreateRefTerm = "otherHttpRequests,header,POSTData"))
static UAsyncNodeHttpDownloadUpload* AsyncExecuteHTTP_Upload_POST_REQUEST(FString url, TMap<FString, FString> header, EHTTPWebComFileUpload DirectoryType, FString filePath, FString fileID, TMap<FString, FString> POSTData, FString optionalRequestID);
/**
* Send multiple files to a Webserver.
*
* @param otherHttpRequests
* @param url Server URL
* @param DirectoryType Absolute or Relative
* @param filePaths paths with filenames at the ends
* @param fileIDs names equivalent to <input type="file" name="myFile"> from an html upload. It is also possible to enter only one file ID for all files.
* @param requestID Optional parameter. It will be output again in the httpRequestComplete event. This allows the request being assigned to the response.
*/
UFUNCTION(BlueprintCallable, Category = "WebCommunication|File Upload", meta = (BlueprintInternalUseOnly = "true", AutoCreateRefTerm = "otherHttpRequests,header,POSTData"))
static UAsyncNodeHttpDownloadUpload* AsyncExecuteHTTP_Multi_Upload_POST_REQUEST(FString url, TMap<FString, FString> header, EHTTPWebComFileUpload DirectoryType, TArray<FString> filePaths, TArray<FString> fileIDs, TMap<FString, FString> POSTData, FString optionalRequestID);
/**
* Send a file to a Webserver.
*
* @param url Server URL
* @param DirectoryType Absolute or Relative
* @param filePath File with path
* @param fileID name equivalent to <input type="file" name="myFile"> from an html upload
* @param uploadType
PUT Stream (Blank):With this option only the file is written into the http body and nothing else. If your server can handle it then use this option. Additionally headers will be created. fileid, filename, fileformat, mimetype
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
PUT Stream (Multiplart):With this option a header is created which goes with a trick into the body and writes the necessary information of the file into the body. Important! The only way to write something at the end of the body is to write this information into the file.
After the upload is finished or canceled the plugin removes this information from the file.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
PUT Stream (Copy Multiplart):This option also writes information to the file. But a copy of the file is created before and the info is written into the copy. The copy will be deleted after the upload. Making a copy of a large file can lead to freezing because it is done in the game thread.
*/
UFUNCTION(BlueprintCallable, Category = "WebCommunication|File Upload", meta = (BlueprintInternalUseOnly = "true", AutoCreateRefTerm = "otherHttpRequests,header"))
static UAsyncNodeHttpDownloadUpload* AsyncExecuteHTTP_Upload_PUT_REQUEST(FString url, TMap<FString, FString> header, EHTTPWebComFileUpload DirectoryType, FString filePath, FString fileID, EHTTPWebComFileUploadType uploadType, FString optionalRequestID);
/**
* Send multiple files to a Webserver.
*
* @param otherHttpRequests
* @param url Server URL
* @param DirectoryType Absolute or Relative
* @param filePaths paths with filenames at the ends
* @param fileIDs names equivalent to <input type="file" name="myFile"> from an html upload. It is also possible to enter only one file ID for all files.
* @param requestID Optional parameter. It will be output again in the httpRequestComplete event. This allows the request being assigned to the response.
*/
UFUNCTION(BlueprintCallable, Category = "WebCommunication|File Upload", meta = (BlueprintInternalUseOnly = "true", AutoCreateRefTerm = "otherHttpRequests,header"))
static UAsyncNodeHttpDownloadUpload* AsyncExecuteHTTP_Multi_Upload_PUT_REQUEST(FString url, TMap<FString, FString> header, EHTTPWebComFileUpload DirectoryType, TArray<FString> filePaths, TArray<FString> fileIDs, FString optionalRequestID);
virtual void Activate() override;
void httpRequestDownloadUploadComplete(const FString dataString, const TArray<FString>& dataArray, const TArray<FString>& header, const int32 statusCode, const FString requestID);
private:
FString requestID;
TArray<struct FhttpRequest> httpRequests;
};