Upload the current block as a single PUT request; if the buffer is empty a
0-byte PUT will be invoked, as it is needed to create an entry at the far
end.

@throws IOException any problem
962961
private void putObject() throws IOException {
    LOG.debug("Executing regular upload for {}", writeOperationHelper);

    final COSDataBlocks.DataBlock block = getActiveBlock();
    int size = block.dataSize();
    final COSDataBlocks.BlockUploadData uploadData = block.startUpload();
    final PutObjectRequest putObjectRequest = uploadData.hasFile()
        ? writeOperationHelper.newPutRequest(uploadData.getFile())
        : writeOperationHelper.newPutRequest(uploadData.getUploadStream(), size);

    final ObjectMetadata om = new ObjectMetadata();
    om.setUserMetadata(mMetadata);
    if (contentType != null && !contentType.isEmpty()) {
      om.setContentType(contentType);
    } else {
      om.setContentType("application/octet-stream");
    }
    putObjectRequest.setMetadata(om);
    ListenableFuture<PutObjectResult> putObjectResult =
        executorService.submit(new Callable<PutObjectResult>() {
          @Override
          public PutObjectResult call() throws Exception {
            PutObjectResult result;
            try {
              // the putObject call automatically closes the input
              // stream afterwards.
              result = writeOperationHelper.putObject(putObjectRequest);
            } finally {
              closeAll(LOG, uploadData, block);
            }
            return result;
          }
        });
    clearActiveBlock();
    // wait for completion
    try {
      putObjectResult.get();
    } catch (InterruptedException ie) {
      LOG.warn("Interrupted object upload", ie);
      Thread.currentThread().interrupt();
    } catch (ExecutionException ee) {
      throw extractException("regular upload", key, ee);
    }
  }
999271
async def _put_chunk(
            cls, session: aiohttp.ClientSession,
            upload_uri: str, buf: bytes):
        """"""
        # Build the correct headers.
        headers = {
            'Content-Type': 'application/octet-stream',
            'Content-Length': '%s' % len(buf),
        }
        credentials = cls._handler.session.credentials
        if credentials is not None:
            utils.sign(upload_uri, headers, credentials)

        # Perform upload of chunk.
        async with await session.put(
                upload_uri, data=buf, headers=headers) as response:
            if response.status != 200:
                content = await response.read()
                request = {
                    "body": buf,
                    "headers": headers,
                    "method": "PUT",
                    "uri": upload_uri,
                }
                raise CallError(request, response, content, None)
994863
public void write(DataOutput out) throws IOException {
    out.writeLong(blockId);
    out.writeLong(blockGenStamp);
    super.write(out);
  }
232970
protected void flushBuffer() throws IOException {
		if (capacity == 0) {
			ostream.write(buffer);
			capacity = BITS_IN_BYTE;
			buffer = 0;
			len++;
		}
	}
1072838
public void putNextEntry(TarEntry entry) throws IOException {
        closeCurrentEntry();

        byte[] header = new byte[TarConstants.HEADER_BLOCK];
        entry.writeEntryHeader( header );

        write( header );

        currentEntry = entry;
    }
1001097
@Override
    protected void uploadTusFiles() throws IOException, ProtocolException {
        setState(State.UPLOADING);
        while (uploads.size() > 0) {
            final TusUploader tusUploader;
            // don't recreate uploader if it already exists.
            // this is to avoid multiple connections being open. And to avoid some connections left unclosed.
            if (lastTusUploader != null) {
                tusUploader = lastTusUploader;
                lastTusUploader = null;
            } else {
                tusUploader = tusClient.resumeOrCreateUpload(uploads.get(0));
                if (getUploadChunkSize() > 0) {
                    tusUploader.setChunkSize(getUploadChunkSize());
                }
            }

            TusExecutor tusExecutor = new TusExecutor() {
                @Override
                protected void makeAttempt() throws ProtocolException, IOException {
                    while (state == State.UPLOADING) {
                        int chunkUploaded = tusUploader.uploadChunk();
                        if (chunkUploaded > 0) {
                            uploadedBytes += chunkUploaded;
                            listener.onUploadPogress(uploadedBytes, totalUploadSize);
                        } else {
                            // upload is complete
                            break;
                        }
                    }
                }
            };

            tusExecutor.makeAttempts();
            if (state != State.UPLOADING) {
                // if upload is paused, save the uploader so it can be reused on resume, then leave the method early.
                lastTusUploader = tusUploader;
                return;
            }

            // remove upload instance from list
            uploads.remove(0);
            tusUploader.finish();
        }

        setState(State.UPLOAD_COMPLETE);
    }
534499
public final static int put(IoBuffer out, IoBuffer in, int numBytesMax) {
        if (log.isTraceEnabled()) {
            log.trace("Put\nin buffer: {}\nout buffer: {}\nmax bytes: {}", new Object[] { out, in, numBytesMax });
        }
        int numBytesRead = 0;
        if (in != null) {
            int limit = Math.min(in.limit(), numBytesMax);
            byte[] inBuf = new byte[limit];
            log.trace("Bulk get size: {}", limit);
            in.get(inBuf);
            byte[] outBuf = consumeBytes(inBuf, numBytesMax);
            out.put(outBuf);
            numBytesRead = outBuf.length;
            log.trace("In pos: {}", in.position());
        }
        log.trace("Bytes put: {}", numBytesRead);
        return numBytesRead;
    }
940895
public FilterByteBuffer put(byte[] src) throws IOException
    {
        checkOut();
        out.write(src);
        position += src.length;
        return this;
    }
1161282
private void record(int b) throws IOException {
        if (this.shouldDigest) {
            this.digest.update((byte)b);
        }
        if (this.position >= this.buffer.length) {
            this.ensureDiskStream().write(b);
        } else {
            this.buffer[(int) this.position] = (byte) b;
        }
        this.position++;
    }
780497
def upload_chunk(self):
        
        self._retried = 0
        self._do_request()
        self.offset = int(self.request.response_headers.get('upload-offset'))
        if self.log_func:
            msg = '{} bytes uploaded ...'.format(self.offset)
            self.log_func(msg)
39391
protected void put(byte[] bytes)
    {
        if (tc.isEntryEnabled()) Tr.entry(tc, "put", new Object[] {RLSUtils.toHexString(bytes, RLSUtils.MAX_DISPLAY_BYTES), this});

        if (tc.isDebugEnabled()) Tr.debug(tc, "Writing at position " + _buffer.position());
        
        _buffer.put(bytes);

        if (tc.isEntryEnabled()) Tr.exit(tc, "put");
    }
174302
public void PUT(OvhNichandle body) throws IOException {
		String qPath = "/me";
		StringBuilder sb = path(qPath);
		exec(qPath, "PUT", sb.toString(), body);
	}
427734
@Override
	public void writeBlock(Buffer buffer) throws IOException {
		try {
			// if successfully added, the buffer will be recycled after the write operation
			addRequest(new BufferWriteRequest(this, buffer));
		} catch (Throwable e) {
			// if not added, we need to recycle here
			buffer.recycleBuffer();
			ExceptionUtils.rethrowIOException(e);
		}

	}
680477
public void add(byte b) throws BufferIsFullException {
        if (isFull()) {
            throw new BufferIsFullException("Buffer is full and has reached maximum capacity (" + capacity() + ")");
        }

        // buffer is not full
        this.buffer[this.currentWritePosition] = b;
        this.currentWritePosition = (this.currentWritePosition + 1) % this.buffer.length;
        this.currentBufferSize += 1;
    }
769541
void loadBlock(BlockId blockId, ByteBuffer block) throws IOException {
        synchronized (m_accessLock) {
            if (! m_blockPathMap.containsKey(blockId)) {
                throw new IllegalArgumentException("Request to load block that is not stored: " + blockId);
            }

            int origPosition = block.position();
            block.position(0);
            Path blockPath = m_blockPathMap.get(blockId);
            try (SeekableByteChannel channel = Files.newByteChannel(blockPath)) {
                channel.read(block);
            }
            finally {
                block.position(origPosition);
            }
        }
    }
546844
protected static void putRecordIntoDeliveryStream() throws IOException {
        try (InputStream inputStream =
                Thread.currentThread().getContextClassLoader().getResourceAsStream(PUT_RECORD_STREAM_SOURCE)) {
            if (inputStream == null) {
                throw new FileNotFoundException("Could not find file " + PUT_RECORD_STREAM_SOURCE);
            }

            try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) {
                String line = null;
                while ((line = reader.readLine()) != null) {
                    PutRecordRequest putRecordRequest = new PutRecordRequest();
                    putRecordRequest.setDeliveryStreamName(deliveryStreamName);

                    String data = line + "\n";
                    Record record = createRecord(data);
                    putRecordRequest.setRecord(record);

                    // Put record into the DeliveryStream
                    firehoseClient.putRecord(putRecordRequest);
                }
            }
        }
    }
9129
@Override
  public void addEntry(Archivable arch) throws IOException {
    final String fn = arch.getFileName();
    TarArchiveEntry entry = new TarArchiveEntry(fn);
    byte[] cbytes = arch.getBytes();
    entry.setSize(cbytes.length);
    this.tos.putArchiveEntry(entry);
    try (ByteArrayInputStream bis = new ByteArrayInputStream(cbytes)) {
      IOUtils.copy(bis, tos);
      tos.closeArchiveEntry();
    }
  }