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

com.huaweicloud.sdk.koomessage.v1.model.UploadMediaRequestBody Maven / Gradle / Ivy

There is a newer version: 3.1.114
Show newest version
package com.huaweicloud.sdk.koomessage.v1.model;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.huaweicloud.sdk.core.http.FormDataFilePart;
import com.huaweicloud.sdk.core.http.FormDataPart;
import com.huaweicloud.sdk.core.http.SdkFormDataBody;

import java.io.InputStream;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;

/**
 * UploadMediaRequestBody
 */
public class UploadMediaRequestBody implements SdkFormDataBody {

    @JsonProperty(value = "file", access = JsonProperty.Access.WRITE_ONLY)

    private FormDataFilePart file;

    @JsonInclude(JsonInclude.Include.NON_NULL)
    @JsonProperty(value = "file_type")

    private String fileType;

    public UploadMediaRequestBody withFile(FormDataFilePart file) {
        this.file = file;
        return this;
    }

    /**
     * 图片资源。  > 文件格式与文件名后缀需保持一致,请勿修改原始文件后缀,否则导致资源上传失败。 
     * @return file
     */
    public FormDataFilePart getFile() {
        return file;
    }

    public void setFile(FormDataFilePart file) {
        this.file = file;
    }

    public UploadMediaRequestBody withFileType(String fileType) {
        this.fileType = fileType;
        return this;
    }

    /**
     * 文件类型。 - PUB_LOGO:上传服务号LOGO。支持jpg、bmp、png和jpeg格式,分辨率大于等于240*240且比例为1:1,大小不超过100K。 - BG_IMAGE:上传服务号主页背景图。分辨率大于等于1440*810。 - FASTAPP_LOGO:上传快应用LOGO。上传快应用LOGO。支持jpg、bmp和jpeg格式,分辨率大于等于192*192,大小不超过4M。 - OTHER:上传授权证明和营业执照等 
     * @return fileType
     */
    public String getFileType() {
        return fileType;
    }

    public void setFileType(String fileType) {
        this.fileType = fileType;
    }

    public UploadMediaRequestBody withFile(InputStream inputStream, String fileName, String contentType) {
        this.file = new FormDataFilePart(inputStream, fileName).withContentType(contentType);
        return this;
    }

    public UploadMediaRequestBody withFile(InputStream inputStream, String fileName) {
        this.file = new FormDataFilePart(inputStream, fileName);
        return this;
    }

    public UploadMediaRequestBody withFile(InputStream inputStream, String fileName, Map headers) {
        this.file = new FormDataFilePart(inputStream, fileName).withHeaders(headers);
        return this;
    }

    @Override
    public Map> buildFormData() {
        return new LinkedHashMap>() {

            private static final long serialVersionUID = 1L;
            {
                put("file", file);
                put("file_type", new FormDataPart<>(fileType));
            }
        };
    }

    @Override
    public boolean equals(java.lang.Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || getClass() != obj.getClass()) {
            return false;
        }
        UploadMediaRequestBody that = (UploadMediaRequestBody) obj;
        return Objects.equals(this.file, that.file) && Objects.equals(this.fileType, that.fileType);
    }

    @Override
    public int hashCode() {
        return Objects.hash(file, fileType);
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("class UploadMediaRequestBody {\n");
        sb.append("    file: ").append(toIndentedString("[resource:will-not-print]")).append("\n");
        sb.append("    fileType: ").append(toIndentedString(fileType)).append("\n");
        sb.append("}");
        return sb.toString();
    }

    /**
     * Convert the given object to string with each line indented by 4 spaces
     * (except the first line).
     */
    private String toIndentedString(java.lang.Object o) {
        if (o == null) {
            return "null";
        }
        return o.toString().replace("\n", "\n    ");
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy