Fix Image management (BMP, BMPtoJPEG) and remove debug info from AWS Upload

This commit is contained in:
2026-04-17 20:59:21 +10:00
parent fcc985efb9
commit a47ea25e8b
4 changed files with 18 additions and 10 deletions

View File

@@ -5594,7 +5594,7 @@ extern "C" __declspec(dllexport) int ANSCV_ImagesToMP4_S(
const char* imageFolder, const char* imageFolder,
const char* outputVideoPath, const char* outputVideoPath,
int maxWidth, int fps) { int maxWidth, int fps) {
return ANSCV_ImagesToMP4FF_S(imageFolder,outputVideoPath,maxWidth,fps); //return ANSCV_ImagesToMP4FF_S(imageFolder,outputVideoPath,maxWidth,fps);
try { try {
if (!imageFolder || strlen(imageFolder) == 0) { if (!imageFolder || strlen(imageFolder) == 0) {
std::cerr << "Error: Invalid image folder path!" << std::endl; std::cerr << "Error: Invalid image folder path!" << std::endl;
@@ -6626,7 +6626,7 @@ struct BmpInfoHeader {
extern "C" __declspec(dllexport) int ANSCV_ImageToBmp(cv::Mat** imageIn, int maxWidth, int& newWidth, int& newHeight, LStrHandle outputImage) { extern "C" __declspec(dllexport) int ANSCV_ImageToBmp(cv::Mat** imageIn, int maxWidth, int& newWidth, int& newHeight, LStrHandle outputImage) {
return ANSCV_GetImage_S(imageIn,maxWidth,80,newWidth,newHeight,outputImage); //return ANSCV_GetImage_S(imageIn,maxWidth,80,newWidth,newHeight,outputImage);
try { try {
if (!imageIn || !(*imageIn) || (*imageIn)->empty() || !outputImage) { if (!imageIn || !(*imageIn) || (*imageIn)->empty() || !outputImage) {
ANS_DBG("ANSCV", "ImageToBmp: invalid input"); ANS_DBG("ANSCV", "ImageToBmp: invalid input");

View File

@@ -1522,6 +1522,7 @@ namespace ANSCENTER
// Uploads text data from a file to the specified S3 bucket // Uploads text data from a file to the specified S3 bucket
bool ANSAWSS3::UploadTextData(const std::string& bucketName, const std::string& textFilePath, std::string& uploadedFilePath) { bool ANSAWSS3::UploadTextData(const std::string& bucketName, const std::string& textFilePath, std::string& uploadedFilePath) {
const std::string kOp = "ANSAWSS3::UploadTextData"; const std::string kOp = "ANSAWSS3::UploadTextData";
// _logger.LogError(kOp,"Start Uploading...",__FILE__, __LINE__);
// Early validation (permanent — do NOT retry) // Early validation (permanent — do NOT retry)
if (!_isLicenseValid || !_isUnlockCodeValid || !_bConnected) { if (!_isLicenseValid || !_isUnlockCodeValid || !_bConnected) {
@@ -1614,6 +1615,7 @@ namespace ANSCENTER
} }
bool ANSAWSS3::UploadBinaryData(const std::string& bucketName, const std::string& dataFilePath, std::string& uploadedFilePath) { bool ANSAWSS3::UploadBinaryData(const std::string& bucketName, const std::string& dataFilePath, std::string& uploadedFilePath) {
const std::string kOp = "ANSAWSS3::UploadBinaryData"; const std::string kOp = "ANSAWSS3::UploadBinaryData";
// _logger.LogError(kOp,"Start Uploading...",__FILE__, __LINE__);
// Early validation (permanent — do NOT retry) // Early validation (permanent — do NOT retry)
if (!_isLicenseValid || !_isUnlockCodeValid || !_bConnected) { if (!_isLicenseValid || !_isUnlockCodeValid || !_bConnected) {
@@ -1691,9 +1693,9 @@ namespace ANSCENTER
return retryable ? AttemptResult::Transient : AttemptResult::Permanent; return retryable ? AttemptResult::Transient : AttemptResult::Permanent;
}); });
} }
bool ANSAWSS3::UploadPrefixBinaryData(const std::string& bucketName, const std::string& prefix, const std::string& dataFilePath, const std::string& objectName, std::string& uploadedFilePath) { bool ANSAWSS3::UploadPrefixBinaryData(const std::string& bucketName, const std::string& prefix, const std::string& dataFilePath, const std::string& objectName, std::string& uploadedFilePath) {
const std::string kOp = "ANSAWSS3::UploadPrefixBinaryData"; const std::string kOp = "ANSAWSS3::UploadPrefixBinaryData";
//_logger.LogError(kOp,"Start Uploading...",__FILE__, __LINE__);
// Early validation (permanent — do NOT retry) // Early validation (permanent — do NOT retry)
if (!_isLicenseValid || !_isUnlockCodeValid || !_bConnected) { if (!_isLicenseValid || !_isUnlockCodeValid || !_bConnected) {
@@ -1795,9 +1797,9 @@ namespace ANSCENTER
return retryable ? AttemptResult::Transient : AttemptResult::Permanent; return retryable ? AttemptResult::Transient : AttemptResult::Permanent;
}); });
} }
bool ANSAWSS3::UploadFileStream(const std::string& bucketName, const std::string& dataFilePath, std::string& uploadedFilePath) { bool ANSAWSS3::UploadFileStream(const std::string& bucketName, const std::string& dataFilePath, std::string& uploadedFilePath) {
const std::string kOp = "ANSAWSS3::UploadFileStream"; const std::string kOp = "ANSAWSS3::UploadFileStream";
//_logger.LogError(kOp,"Start Uploading...",__FILE__, __LINE__);
// Early validation (permanent — do NOT retry) // Early validation (permanent — do NOT retry)
if (!_isLicenseValid || !_isUnlockCodeValid || !_bConnected) { if (!_isLicenseValid || !_isUnlockCodeValid || !_bConnected) {
@@ -1867,6 +1869,7 @@ namespace ANSCENTER
} }
bool ANSAWSS3::UploadMultipartData(const std::string& bucketName,const std::string& dataFilePath, std::string& uploadedFilePath, int partSize) { bool ANSAWSS3::UploadMultipartData(const std::string& bucketName,const std::string& dataFilePath, std::string& uploadedFilePath, int partSize) {
const std::string kOp = "ANSAWSS3::UploadMultipartData"; const std::string kOp = "ANSAWSS3::UploadMultipartData";
//_logger.LogError(kOp,"Start Uploading...",__FILE__, __LINE__);
// Early validation (permanent — do NOT retry) // Early validation (permanent — do NOT retry)
if (!_isLicenseValid || !_isUnlockCodeValid || !_bConnected) { if (!_isLicenseValid || !_isUnlockCodeValid || !_bConnected) {
@@ -2067,6 +2070,7 @@ namespace ANSCENTER
} }
bool ANSAWSS3::UploadPrefixMultipartData(const std::string& bucketName, const std::string& prefix,const std::string& dataFilePath, const std::string& objectName, std::string& uploadedFilePath, int partSize) { bool ANSAWSS3::UploadPrefixMultipartData(const std::string& bucketName, const std::string& prefix,const std::string& dataFilePath, const std::string& objectName, std::string& uploadedFilePath, int partSize) {
const std::string kOp = "ANSAWSS3::UploadPrefixMultipartData"; const std::string kOp = "ANSAWSS3::UploadPrefixMultipartData";
//_logger.LogError(kOp,"Start Uploading...",__FILE__, __LINE__);
// Early validation (permanent — do NOT retry) // Early validation (permanent — do NOT retry)
if (!_isLicenseValid || !_isUnlockCodeValid || !_bConnected) { if (!_isLicenseValid || !_isUnlockCodeValid || !_bConnected) {
@@ -2284,7 +2288,7 @@ namespace ANSCENTER
// Upload jpeg data // Upload jpeg data
bool ANSAWSS3::UploadJpegImage(const std::string& bucketName, unsigned char* jpeg_string, int32 bufferLength, const std::string& fileName, std::string& uploadedFilePath) { bool ANSAWSS3::UploadJpegImage(const std::string& bucketName, unsigned char* jpeg_string, int32 bufferLength, const std::string& fileName, std::string& uploadedFilePath) {
const std::string kOp = "ANSAWSS3::UploadJpegImage"; const std::string kOp = "ANSAWSS3::UploadJpegImage";
// _logger.LogError(kOp,"Start Uploading...",__FILE__, __LINE__);
// Early validation checks (permanent — do NOT retry) // Early validation checks (permanent — do NOT retry)
if (!_isLicenseValid || !_isUnlockCodeValid || !_bConnected) { if (!_isLicenseValid || !_isUnlockCodeValid || !_bConnected) {
_logger.LogError(kOp, _logger.LogError(kOp,
@@ -2356,7 +2360,7 @@ namespace ANSCENTER
} }
bool ANSAWSS3::UploadPrefixJpegImage(const std::string& bucketName, const std::string& prefix,unsigned char* jpeg_string,int32 bufferLength,const std::string& fileName, std::string& uploadedFilePath) { bool ANSAWSS3::UploadPrefixJpegImage(const std::string& bucketName, const std::string& prefix,unsigned char* jpeg_string,int32 bufferLength,const std::string& fileName, std::string& uploadedFilePath) {
const std::string kOp = "ANSAWSS3::UploadPrefixJpegImage"; const std::string kOp = "ANSAWSS3::UploadPrefixJpegImage";
//_logger.LogError(kOp,"Start Uploading...",__FILE__, __LINE__);
// Early validation checks (permanent failures — do NOT retry) // Early validation checks (permanent failures — do NOT retry)
if (!_isLicenseValid || !_isUnlockCodeValid || !_bConnected) { if (!_isLicenseValid || !_isUnlockCodeValid || !_bConnected) {
_logger.LogError(kOp, _logger.LogError(kOp,
@@ -2427,7 +2431,7 @@ namespace ANSCENTER
// addressing style) — always the canonical path-style URL. // addressing style) — always the canonical path-style URL.
std::string scheme = _bTls ? "https://" : "http://"; std::string scheme = _bTls ? "https://" : "http://";
uploadedFilePath = scheme + _fullAWSURL + "/" + bucketName + "/" + objectKey; uploadedFilePath = scheme + _fullAWSURL + "/" + bucketName + "/" + objectKey;
_logger.LogDebug(kOp, _logger.LogError(kOp,
"Successfully uploaded: " + objectKey + " (" + std::to_string(bufferLength) + " bytes) | URL: " + uploadedFilePath, "Successfully uploaded: " + objectKey + " (" + std::to_string(bufferLength) + " bytes) | URL: " + uploadedFilePath,
__FILE__, __LINE__); __FILE__, __LINE__);
ReleaseConnection(std::move(conn)); ReleaseConnection(std::move(conn));

View File

@@ -1801,7 +1801,11 @@ extern "C" ANSULT_API int UploadJpegImageANSAWSHandle(ANSCENTER::ANSAWSS3** Han
} }
} }
extern "C" ANSULT_API int UploadPrefixJpegImageANSAWSHandle(ANSCENTER::ANSAWSS3** Handle, const char* bucketName, const char* prefix, unsigned char* jpeg_string, int32 bufferLength, const char* fileName, LStrHandle uploadedFilePath) { extern "C" ANSULT_API int UploadPrefixJpegImageANSAWSHandle(ANSCENTER::ANSAWSS3** Handle, const char* bucketName, const char* prefix, unsigned char* jpeg_string, int32 bufferLength, const char* fileName, LStrHandle uploadedFilePath) {
if (Handle == nullptr || *Handle == nullptr || bucketName == nullptr || prefix == nullptr || jpeg_string == nullptr || bufferLength <= 0 || fileName == nullptr || uploadedFilePath == nullptr) { if (Handle == nullptr || *Handle == nullptr ||
bucketName == nullptr || prefix == nullptr ||
jpeg_string == nullptr || bufferLength <= 0 ||
fileName == nullptr || uploadedFilePath == nullptr)
{
return 0; return 0;
} }
AWSHandleGuard guard(AcquireAWSHandle(*Handle)); AWSHandleGuard guard(AcquireAWSHandle(*Handle));

View File

@@ -388,8 +388,8 @@ int ANSLLMOllamaTest() {
int main() int main()
{ {
ANSLLMOllamaTest(); //ANSLLMOllamaTest();
//ANSAWSTest(); ANSAWSTest();
//ANSFTechMinIOTest(); //ANSFTechMinIOTest();
//ANSAWSTest(); //ANSAWSTest();
//ANSLLMTest(); //ANSLLMTest();