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
+40 -10
View File
@@ -37,7 +37,10 @@ namespace PWAPPv2.Source.Attachments
SupportedImageTypes.Add(".jpeg");
SupportedImageTypes.Add(".jpg");
SupportedImageTypes.Add(".png");
//SupportedImageTypes.Add(".tiff");
SupportedImageTypes.Add(".tiff");
SupportedImageTypes.Add(".tif");
SupportedImageTypes.Add(".gif");
SupportedImageTypes.Add(".bmp");
SupportedDocumentTypes.Clear();
SupportedDocumentTypes.Add(".pdf");
@@ -108,23 +111,50 @@ namespace PWAPPv2.Source.Attachments
}
foreach(DataObjects.Attachment attachment in Attachments)
{
PWAttachment att = null;
//PWAttachment att = null;
PWBaseAttachment ba = null;
List<PWFileUpload> fileUploads = new List<PWFileUpload>();
if (attachment.image != null)
{
att = AttachmentFactory.BuildAttachment(credentials, token, attachment.image);
//att = AttachmentFactory.BuildAttachment(credentials, token, attachment.image);
ba = AttachmentFactory.BuildBaseAttachment(token, attachment.image);
//fileUploads.Add(attachment.image.GetFileUploads(attachment.co))
string json = JsonSerializer.Serialize(ba);
string contId = connection.SendPostWithCredsInHeader("api/PWAddAttachment", json);
contId = contId.Replace("\"", "").Replace("\\n", "").Trim();
fileUploads = attachment.image.GetFileUploads(token, contId);
foreach(PWFileUpload file in fileUploads)
{
json = JsonSerializer.Serialize(file);
connection.SendPostWithCredsInHeader("api/PWUploadFile", json);
}
}
else if (attachment.pdf != null)
{
att = AttachmentFactory.BuildAttachment(credentials, token, attachment.pdf);
//att = AttachmentFactory.BuildAttachment(credentials, token, attachment.pdf);
ba = AttachmentFactory.BuildBaseAttachment(token, attachment.pdf);
string json = JsonSerializer.Serialize(ba);
string contId = connection.SendPostWithCredsInHeader("api/PWAddAttachment", json);
fileUploads = attachment.pdf.GetFileUploads(token, contId);
foreach (PWFileUpload file in fileUploads)
{
json = JsonSerializer.Serialize(file);
connection.SendPostWithCredsInHeader("api/PWUploadFile", json);
}
}
if (att == null)
{
throw new AttachmentTypeNotYetSupportedException();
}
string json = JsonSerializer.Serialize(att);
connection.SendPostWithCredsInHeader("api/PWAttachment", json);
//if (att == null)
//{
// throw new AttachmentTypeNotYetSupportedException();
//}
//string json = JsonSerializer.Serialize(att);
//connection.SendPostWithCredsInHeader("api/PWAttachment", json);
//json = JsonSerializer.Serialize(ba);
//connection.SendPostWithCredsInHeader("api/PWAddAttachment", json);
}
}