@ DoesServiceRequest public void uploadRange ( final InputStream sourceStream , final long offset , final long length , final AccessCondition accessCondition , FileRequestOptions options , OperationContext opContext ) throws StorageException , IOException , URISyntaxException { if ( opContext == null ) { opContext = new OperationContext ( ) ; } this . getShare ( ) . assertNoSnapshot ( ) ; options = FileRequestOptions . populateAndApplyDefaults ( options , this . fileServiceClient ) ; final FileRange range = new FileRange ( offset , offset + length - 1 ) ; final byte [ ] data = new byte [ ( int ) length ] ; String md5 = null ; int count = 0 ; int total = 0 ; while ( total < length ) { count = sourceStream . read ( data , total , ( int ) Math . min ( length - total , Integer . MAX_VALUE ) ) ; total += count ; } if ( options . getUseTransactionalContentMD5 ( ) ) { try { final MessageDigest digest = MessageDigest . getInstance ( "MD5" ) ; digest . update ( data , 0 , data . length ) ; md5 = Base64 . encode ( digest . digest ( ) ) ; } catch ( final NoSuchAlgorithmException e ) { // This wont happen, throw fatal. throw Utility . generateNewUnexpectedStorageException ( e ) ; } } this . putRangeInternal ( range , FileRangeOperationType . UPDATE , data , length , md5 , accessCondition , options , opContext ) ; }
Uploads a range to a file using the specified lease ID request options and operation context .