src/main/java/com/qingstor/sdk/upload/UploadManager.java
public void putFile(File file, final String objectKey,
                        String fileName, long length) throws QSException {
        PutObjectInput input = new PutObjectInput();
        input.setContentLength(length);
        input.setBodyInputFile(file);
        // Set content disposition to the object.
        if (!QSStringUtil.isEmpty(fileName)) {
            try {
                String keyName = QSStringUtil.percentEncode(fileName, "UTF-8");
                input.setContentDisposition(String.format(
                        "attachment; filename=\"%s\"; filename*=utf-8''%s", keyName, keyName));
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
        }

        RequestHandler requestHandler = bucket.putObjectRequest(objectKey, input);

        // Set progress listener.
        if (progressListener != null) {
            requestHandler.setProgressListener(new BodyProgressListener() {
                @Override
                public void onProgress(long len, long size) {
                    progressListener.onProgress(objectKey, len, size);
                }
            });
        }

        // Cancellation handler.
        requestHandler.setCancellationHandler(cancellationHandler);

        // Sign if needed.
        sign(requestHandler);

        OutputModel outputModel = requestHandler.send();
        if (callBack != null)
            callBack.onAPIResponse(objectKey, outputModel);
    }
public void putFile(File file, final String objectKey,
                        String fileName, long length) throws QSException {
        PutObjectInput input = new PutObjectInput();
        input.setContentLength(length);
        input.setBodyInputFile(file);
        // Set content disposition to the object.
        if (!QSStringUtil.isEmpty(fileName)) {
            try {
                String keyName = QSStringUtil.percentEncode(fileName, "UTF-8");
                input.setContentDisposition(String.format(
                        "attachment; filename=\"%s\"; filename*=utf-8''%s", keyName, keyName));
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
        }

        RequestHandler requestHandler = bucket.putObjectRequest(objectKey, input);

        // Set progress listener.
        if (progressListener != null) {
            requestHandler.setProgressListener(new BodyProgressListener() {
                @Override
                public void onProgress(long len, long size) {
                    progressListener.onProgress(objectKey, len, size);
                }
            });
        }

        // Cancellation handler.
        requestHandler.setCancellationHandler(cancellationHandler);

        // Sign if needed.
        sign(requestHandler);

        OutputModel outputModel = requestHandler.send();
        if (callBack != null)
            callBack.onAPIResponse(objectKey, outputModel);
    }
public void putFile ( File file , final String objectKey , String fileName , long length ) throws QSException { PutObjectInput input = new PutObjectInput ( ) ; input . setContentLength ( length ) ; input . setBodyInputFile ( file ) ; // Set content disposition to the object. if ( ! QSStringUtil . isEmpty ( fileName ) ) { try { String keyName = QSStringUtil . percentEncode ( fileName , "UTF-8" ) ; input . setContentDisposition ( String . format ( "attachment; filename=\"%s\"; filename*=utf-8''%s" , keyName , keyName ) ) ; } catch ( UnsupportedEncodingException e ) { e . printStackTrace ( ) ; } } RequestHandler requestHandler = bucket . putObjectRequest ( objectKey , input ) ; // Set progress listener. if ( progressListener != null ) { requestHandler . setProgressListener ( new BodyProgressListener ( ) { @ Override public void onProgress ( long len , long size ) { progressListener . onProgress ( objectKey , len , size ) ; } } ) ; } // Cancellation handler. requestHandler . setCancellationHandler ( cancellationHandler ) ; // Sign if needed. sign ( requestHandler ) ; OutputModel outputModel = requestHandler . send ( ) ; if ( callBack != null ) callBack . onAPIResponse ( objectKey , outputModel ) ; }
Upload a file with a simple put object upload as a sync request. <br>
If a file's size is less than {@link UploadManager#partSize}, there will call this method.
@param file file
@param objectKey key of the object in the bucket
@param fileName file name of response(content-disposition) when downloaded
@param length length of the file
@throws QSException exception
Upload a file with a simple put object upload as a sync request . <br > If a file s size is less than {