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

com.ksyun.ks3.service.request.AppendObjectRequest Maven / Gradle / Ivy

package com.ksyun.ks3.service.request;

import com.ksyun.ks3.dto.ObjectMetadata;
import com.ksyun.ks3.http.Request;

import java.io.File;
import java.io.InputStream;

import static com.ksyun.ks3.exception.client.ClientIllegalArgumentExceptionGenerator.between;
import static com.ksyun.ks3.exception.client.ClientIllegalArgumentExceptionGenerator.notNull;

/**
 * @author lijunwei[[email protected]]  
 *
 * @date 2014年10月22日 上午10:28:06
 *
 * @description 上传文件的请求
 * 

* 提供通过文件来上传,请使用AppendbjectRequest(String bucketname, String key, File file)这个构造函数 *

* 提供通过流来上传,请使用AppendbjectRequest(String bucketname, String key,InputStream inputStream, ObjectMetadata metadata)这个构造函数,使用时请尽量在metadata中提供content-length,否则有可能导致jvm内存溢出。可以再metadata中指定contentMD5 *

**/ public class AppendObjectRequest extends PutObjectRequest { private Long position; public AppendObjectRequest(String bucketname, String key, File file) { super(bucketname, key, file); } public AppendObjectRequest(String bucketname, String key, InputStream inputStream, ObjectMetadata metadata) { super(bucketname, key, inputStream, metadata); } public Long getPosition() { return position; } public void setPosition(Long position) { this.position = position; } @Override public void validateParams() throws IllegalArgumentException { super.validateParams(); if (this.position == null) throw notNull("position"); if (this.position < 0 || this.position > 5368709120L) { throw between("position", String.valueOf(this.position), "0", "5368709120L"); } } @Override public void buildRequest(Request request) { request.addQueryParam("append", ""); request.addQueryParam("position", String.valueOf(this.position)); super.buildRequest(request); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy