All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.greenapi.client.examples.SendFileByUploadExample Maven / Gradle / Ivy

There is a newer version: 0.1.8
Show newest version
package com.greenapi.client.examples;

import com.greenapi.client.pkg.models.request.OutgoingFileByUpload;
import com.greenapi.client.pkg.api.GreenApi;
import lombok.extern.log4j.Log4j2;

import java.io.File;
import java.util.Objects;

@Log4j2
public class SendFileByUploadExample {

    private void sendFileByUploadExample(GreenApi greenApi) {
        var file = new File("User/username/folder/Go-Logo_Blue.svg");

        var response = greenApi.sending.sendFileByUpload(OutgoingFileByUpload.builder()
            .file(file)
            .fileName(file.getName())
            .chatId("[email protected]")
            .build());

        if (response.getStatusCode().isError()) {
            log.warn("message sending is failed");
        }

        log.info("message sent, id: " + Objects.requireNonNull(response.getBody()).getIdMessage());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy