Modified how attachments are pushed to the API.
Added support for BMP and GIF image types.
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PWAPPv2.Source.DataObjects
|
||||
{
|
||||
interface PWFile
|
||||
{
|
||||
List<Attachments.PWFileUpload> GetFileUploads(string attToken, string ContentId);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using PWAPPv2.Source.Attachments;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
@@ -7,7 +8,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace PWAPPv2.Source.DataObjects
|
||||
{
|
||||
public class PWPdf
|
||||
public class PWPdf : PWFile
|
||||
{
|
||||
public string path;
|
||||
|
||||
@@ -23,6 +24,17 @@ namespace PWAPPv2.Source.DataObjects
|
||||
return Convert.ToBase64String(bytes);
|
||||
}
|
||||
|
||||
public List<PWFileUpload> GetFileUploads(string attToken, string ContentId)
|
||||
{
|
||||
List<PWFileUpload> fileUploads = new List<PWFileUpload>();
|
||||
PWFileUpload file = new PWFileUpload();
|
||||
file.Base64Content = GetBase64String();
|
||||
file.ContentId = ContentId;
|
||||
file.AttToken = attToken;
|
||||
fileUploads.Add(file);
|
||||
return fileUploads;
|
||||
}
|
||||
|
||||
public string ShortFileName()
|
||||
{
|
||||
return path.Substring(path.LastIndexOf("\\") + 1);
|
||||
|
||||
Reference in New Issue
Block a user