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

com.pengrad.telegrambot.request.AbstractUploadRequest Maven / Gradle / Ivy

There is a newer version: 7.11.0
Show newest version
package com.pengrad.telegrambot.request;

import com.pengrad.telegrambot.response.BaseResponse;

import java.io.File;

/**
 * Stas Parshin
 * 23 July 2017
 */
abstract public class AbstractUploadRequest, R extends BaseResponse> extends BaseRequest {

    private final boolean isMultipart;

    public AbstractUploadRequest(Class responseClass, String paramName, Object data) {
        super(responseClass);
        if (data instanceof String) {
            isMultipart = false;
        } else if (data instanceof File) {
            isMultipart = true;
        } else if (data instanceof byte[]) {
            isMultipart = true;
        } else {
            throw new IllegalArgumentException("Sending data should be String, File or byte[]");
        }
        add(paramName, data);
    }

    @Override
    public boolean isMultipart() {
        return isMultipart;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy