Modified how attachments are pushed to the API.

Added support for BMP and GIF image types.
This commit is contained in:
goomatt33
2024-03-25 13:21:14 -04:00
parent f31302438d
commit 205b3d8014
10 changed files with 202 additions and 17 deletions
+43 -4
View File
@@ -1,11 +1,14 @@
using System;
using PWAPPv2.Source.Attachments;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
namespace PWAPPv2.Source.DataObjects
{
public class PWImage
public class PWImage : PWFile
{
private string ImagePath;
@@ -30,14 +33,26 @@ namespace PWAPPv2.Source.DataObjects
string extension = Path.GetExtension(path).ToLower();
if(extension == ".jpeg" || extension == ".jpg")
if (extension == ".jpeg" || extension == ".jpg")
{
FileType = "image/jpeg";
}
else if(extension == ".png")
else if (extension == ".png")
{
FileType = "image/png";
}
else if (extension == ".tiff" || extension == ".tif")
{
FileType = "image/tiff";
}
else if(extension == ".gif")
{
FileType = "image/gif";
}
else if(extension == ".bmp")
{
FileType = "image/bmp";
}
//bmp = (Bitmap)System.Drawing.Image.FromFile(ImagePath);
//thumb = resize(bmp, 50, 50);
@@ -118,5 +133,29 @@ namespace PWAPPv2.Source.DataObjects
return str;
}
public List<PWFileUpload> GetFileUploads(string attToken, string ContentId)
{
List<PWFileUpload> fileUploads = new List<PWFileUpload>();
PWFileUpload baseImage = new PWFileUpload();
baseImage.ContentId = ContentId;
baseImage.Base64Content = GetBase64String();
baseImage.AttToken = attToken;
PWFileUpload zoom = new PWFileUpload();
zoom.Base64Content = GetBase64ZoomString();
zoom.ContentId = ContentId;
zoom.Tag = "_zoom";
zoom.AttToken = attToken;
PWFileUpload thumb = new PWFileUpload();
thumb.Base64Content= GetBase64ThumbString();
thumb.ContentId = ContentId;
thumb.Tag = "_th";
thumb.AttToken = attToken;
fileUploads.Add(baseImage);
fileUploads.Add(zoom);
fileUploads.Add(thumb);
return fileUploads;
}
}
}