src/main/java/com/qingstor/sdk/upload/UploadManager.java
public void put(File file, String objectKey, String fileName, String eTag) throws QSException {
        // Check the file does exist or not.
        if (!file.exists() || file.isDirectory())
            throw new QSException("File does not exist or it is a directory.");

        // Check file's length.
        long length = file.length();
        if (length < 1) throw new QSException("The size of file cannot be smaller than 1 byte.");
        if (length <= partSize) {
            partCounts = 1;
            putFile(file, objectKey, fileName, length);
        } else { // Do multi uploads.
            // Calculate part counts.
            if (length / partSize > MAX_PART_COUNTS) {
                partSize = length / MAX_PART_COUNTS;
                partCounts = MAX_PART_COUNTS;
                // Check every part's size(max 5GB).
                if (partSize > 5 * 1024 * 1024 * 1024L)
                    throw new QSException("The size of file is too large.");
            } else {
                partCounts = (int) (length / partSize);
                if (length % partSize > 0) partCounts += 1;
            }
            putFileMulti(file, objectKey, fileName, eTag, length);
        }
    }
public void put(File file, String objectKey, String fileName, String eTag) throws QSException {
        // Check the file does exist or not.
        if (!file.exists() || file.isDirectory())
            throw new QSException("File does not exist or it is a directory.");

        // Check file's length.
        long length = file.length();
        if (length < 1) throw new QSException("The size of file cannot be smaller than 1 byte.");
        if (length <= partSize) {
            partCounts = 1;
            putFile(file, objectKey, fileName, length);
        } else { // Do multi uploads.
            // Calculate part counts.
            if (length / partSize > MAX_PART_COUNTS) {
                partSize = length / MAX_PART_COUNTS;
                partCounts = MAX_PART_COUNTS;
                // Check every part's size(max 5GB).
                if (partSize > 5 * 1024 * 1024 * 1024L)
                    throw new QSException("The size of file is too large.");
            } else {
                partCounts = (int) (length / partSize);
                if (length % partSize > 0) partCounts += 1;
            }
            putFileMulti(file, objectKey, fileName, eTag, length);
        }
    }
public void put ( File file , String objectKey , String fileName , String eTag ) throws QSException { // Check the file does exist or not. if ( ! file . exists ( ) || file . isDirectory ( ) ) throw new QSException ( "File does not exist or it is a directory." ) ; // Check file's length. long length = file . length ( ) ; if ( length < 1 ) throw new QSException ( "The size of file cannot be smaller than 1 byte." ) ; if ( length <= partSize ) { partCounts = 1 ; putFile ( file , objectKey , fileName , length ) ; } else { // Do multi uploads. // Calculate part counts. if ( length / partSize > MAX_PART_COUNTS ) { partSize = length / MAX_PART_COUNTS ; partCounts = MAX_PART_COUNTS ; // Check every part's size(max 5GB). if ( partSize > 5 * 1024 * 1024 * 1024L ) throw new QSException ( "The size of file is too large." ) ; } else { partCounts = ( int ) ( length / partSize ) ; if ( length % partSize > 0 ) partCounts += 1 ; } putFileMulti ( file , objectKey , fileName , eTag , length ) ; } }
Upload a file with a sync request.
@param file file
@param objectKey key of the object in the bucket
@param fileName file name of response(content-disposition) when downloaded
@param eTag MD5 info
@throws QSException exception
Upload a file with a sync request .