From ce812fee6cffd26ff4e4864680c0e43dd5aca37e Mon Sep 17 00:00:00 2001 From: nikkel Date: Fri, 20 Mar 2020 03:21:02 +0700 Subject: [PATCH] Upload files to 'src/main/java/ca/mgamble/postman/api/message' --- .../postman/api/message/Attachment.java | 52 +++++++++++++++++++ .../postman/api/message/EmbeddedImage.java | 24 +++++++++ 2 files changed, 76 insertions(+) create mode 100644 src/main/java/ca/mgamble/postman/api/message/Attachment.java create mode 100644 src/main/java/ca/mgamble/postman/api/message/EmbeddedImage.java diff --git a/src/main/java/ca/mgamble/postman/api/message/Attachment.java b/src/main/java/ca/mgamble/postman/api/message/Attachment.java new file mode 100644 index 0000000..dfc5e67 --- /dev/null +++ b/src/main/java/ca/mgamble/postman/api/message/Attachment.java @@ -0,0 +1,52 @@ + +package ca.mgamble.postman.api.message; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Base64; + +/** + * + * @author mgamble + */ +/* +The MIT License (MIT) + +Copyright (c) 2017 Matthew M. Gamble https://www.mgamble.ca + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + */ +@Data +@NoArgsConstructor +public class Attachment { + private String name; + private String content_type; + private String data; + + public Attachment(String name, String content_type, String data) { + this.name = name; + this.content_type = content_type; + this.data = data; + } + + public Attachment(String name, String content_type, byte[] data) { + this(name, content_type, new String(Base64.getEncoder().encode(data))); + } +} diff --git a/src/main/java/ca/mgamble/postman/api/message/EmbeddedImage.java b/src/main/java/ca/mgamble/postman/api/message/EmbeddedImage.java new file mode 100644 index 0000000..7802ff5 --- /dev/null +++ b/src/main/java/ca/mgamble/postman/api/message/EmbeddedImage.java @@ -0,0 +1,24 @@ +package ca.mgamble.postman.api.message; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Base64; + +@Data +@NoArgsConstructor +public class EmbeddedImage { + private String cidReferenceName; + private String contentType; + private String data; + + public EmbeddedImage(String cidReferenceName, String contentType, String data) { + this.cidReferenceName = cidReferenceName; + this.contentType = contentType; + this.data = data; + } + + public EmbeddedImage(String cidReferenceName, String contentType, byte[] data) { + this(cidReferenceName, contentType, new String(Base64.getEncoder().encode(data))); + } +}