Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP client from linthumbnail #596

Open
vttranlina opened this issue Mar 13, 2023 · 7 comments
Open

HTTP client from linthumbnail #596

vttranlina opened this issue Mar 13, 2023 · 7 comments
Labels

Comments

@vttranlina
Copy link
Member

vttranlina commented Mar 13, 2023

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�8x�4����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--
@quantranhong1999
Copy link
Member

So default (without specifying size query param), the linshare thumbnail server return all 3 sizes?

BTW can we try to see the size and quality of the 3 sizes?
rf: #593 (comment)

@chibenwa
Copy link
Member

OutputStream is not a reactive type.

We should have a type the represent the actual structure.

@chibenwa
Copy link
Member

Time that it takes to generate the thumbnail?

@vttranlina
Copy link
Member Author

Time that it takes to generate the thumbnail?

Generate thumbnail is a synch request, time depends on the size of the payload, network, and workload of the thumbnail server
On my local PC, the odt file has a size 3.2MB, it takes time = 1341 ms

@chibenwa
Copy link
Member

On my local PC, the odt file has a size 3.2MB, it takes time = 1341 ms

:-(

... Let's make a cache for this then!

Key: SHA-256(byte stream of the attachment)
Value: byte stream of the attachment

Technology to implement the cache: caffeine

@chibenwa
Copy link
Member

ThumbGenerateResponse => ThumbnailGenerationResponse

@chibenwa
Copy link
Member

ThumbnailHttpClient => ThumbnailGenerator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants