huaweicloud / huaweicloud-sdk-java-obs

The OBS SDK for Java, which is used for accessing Object Storage Service
Other
135 stars 116 forks source link

File-Based Upload Error #29

Closed furkanozbay closed 3 years ago

furkanozbay commented 4 years ago

Performing file based upload (described in here: https://support.huaweicloud.com/en-us/sdk-java-devg-obs/obs_21_0603.html) gives error.

Version: 3.20.6

In RequestConvertor class

long fileSize = request.getFile().length();

this line raised error because of method call, length(), on null object: request.getFile()

This is caused from this line

request.setInput(new FileInputStream(request.getFile()));

When you set input to request it sets file to null. This is the setInput method in PutObjectRequest class

    public void setInput(InputStream input) {
        this.input = input;
        this.file = null;
    }
goodcode-best commented 4 years ago

Thanks for your suggestion, this place is indeed a problem and has been fixed in 3.20.6.1:https://mvnrepository.com/artifact/com.huaweicloud/esdk-obs-java/3.20.6.1