tmail-backend
tmail-backend copied to clipboard
HTTP client from linthumbnail
Why
In order to get a thumbnail image from the mail attachment file. Create an HTTP Client for request to linthumbnail server.
How
The client like RspamdHttpClient
public class ThumbGenerateResponse {
private byte[] image
}
public interface ThumbnailHttpClient {
Publisher<ThumbGenerateResponse> get(byte[] attachmentPayload, MimeType mimeType);
}
public class LinshareThumbnailHttpClient implements ThumbnailHttpClient {
private final HttpClient httpClient;
public LinshareThumbnailHttpClient(LinshareThumbnailConfigure configure) {
this.httpClient = ...;
}
@Override
public Publisher<ThumbGenerateResponse> get(byte[] attachmentPayload, MimeType mimeType) {
// todo
return null;
}
}
Bonus
- linthumbnail server docker
docker run -p 8080:8080 --name linshare_thumbnail-server linagora/linshare-thumbnail-server:2.1.1
- Request sample :
curl --location --request POST 'localhost:8080/linthumbnail?mimeType=image/jpeg' \
--form 'file=@"/home/tungtv/Pictures/cmndChanDung.jpg"'
- Response sample:
Content-Type: multipart/mixed;boundary=Boundary_1_1448027541_1678681426294
--Boundary_1_1448027541_1678681426294
Content-Type: text/plain
Content-Disposition: attachement; filename="SMALL.png"
�PNG
�+�n+�_U_G<���o)E��Ld�B��� ��C�+�j�D
6ky�ǖ ����t~O^eԣ�ь��
������d�8x4����IEND�B`�
--Boundary_1_1448027541_1678681426294
Content-Type: text/plain
Content-Disposition: attachement; filename="LARGE.png"
�PNG
���
IHDR����7��GY[��o+�����w6��`
--Boundary_1_1448027541_1678681426294
Content-Type: text/plain
Content-Disposition: attachement; filename="MEDIUM.png"
�PNG
���
IHDR�����X����
--Boundary_1_1448027541_1678681426294--