uploads a single chunk of a multi-chunk upload
777735
def upload_chunk(resource, bytes, bytes_start, bytes_read)
      headers = {
        'content-type'   => content_type,
        'content-length' => bytes.size,
        'content-range'  => "bytes #{bytes_start}-#{bytes_read - 1}/#{@file_size}"
      }
      response = TwitterAds::Request.new(
        @client, :put, resource, domain: DEFAULT_DOMAIN, headers: headers, body: bytes).perform

      yield(response)
      response
    end
733817
private int sendChunks(ByteBuffer pkt, int maxChunks, OutputStream out) 
                         throws IOException {
    // Sends multiple chunks in one packet with a single write().

    int len = (int) Math.min(endOffset - offset,
                            (((long) bytesPerChecksum) * ((long) maxChunks)));

    // truncate len so that any partial chunks will be sent as a final packet.
    // this is not necessary for correctness, but partial chunks are 
    // ones that may be recomputed and sent via buffer copy, so try to minimize
    // those bytes
    if (len > bytesPerChecksum && len % bytesPerChecksum != 0) {
      len -= len % bytesPerChecksum;
    }

    if (len == 0) {
      return 0;
    }

    int numChunks = (len + bytesPerChecksum - 1)/bytesPerChecksum;
    int packetLen = len + numChunks*checksumSize + 4;
    pkt.clear();

    // The packet format is documented in DFSOuputStream.Packet.getBuffer().
    // Here we need to use the exact packet format since it can be received
    // by both of DFSClient, or BlockReceiver in the case of replication, which
    // uses the same piece of codes as receiving data from DFSOutputStream.
    //

    // write packet header
    pkt.putInt(packetLen);
    if (pktIncludeVersion) {
      pkt.putInt(packetVersion);
    }
    pkt.putLong(offset);
    pkt.putLong(seqno);
    pkt.put((byte)((offset + len >= endOffset) ? 1 : 0));
               //why no ByteBuf.putBoolean()?
    pkt.putInt(len);
    
    int checksumOff = pkt.position();
    byte[] buf = pkt.array();
    
    blockReader.sendChunks(out, buf, offset, checksumOff,
        numChunks, len, crcUpdater, packetVersion);
    
    if (throttler != null) { // rebalancing so throttle
      throttler.throttle(packetLen);
    }
    
    return len;
  }
270765
function multipartEncoded(gw, callback){
  var upload = new formidable.IncomingForm();
  var files = {};
  var fields = {};    

  gw.eventium.on('end',cleanTemp);

  upload.uploadDir = tempDirectory;
  upload.keepExtensions = true;
  upload.onPart = function(part) {
    if (part.filename!="") {
      upload.handlePart(part);
    }
  }
  upload
    .on('progress', function(bytesReceived, bytesExpected) {
      var percent_complete = (bytesReceived / bytesExpected) * 100;
    })
    .on('error', function (error) {gw.error(500,error);})
    .on('field', function (field, value) {
      if (fields[field]) {
        if (!Array.isArray(fields[field])) {fields[field]=[fields[field]];}
        fields[field].push(value);
      } else {
        fields[field]=value;
      }
    })
    .on('file', function(field, file) {
      file.ext =  file.name.replace(/^.*\./,'');
      if (fields[field]) {
        if(!Array.isArray(fields[field])){fields[field]=[fields[field]];}
        fields[field].push(file);
      } else {
        fields[field]=file;
      }
      if (files[field]) {
        if (!Array.isArray(files[field])) {files[field]=[files[field]];}
        files[field].push(file);
      } else {
        files[field]=file;
      }
    })
    .on('end', function() {
      fields = gw.constructor.queryHeap(fields);
      gw.content.params = fields;
      for(var i=0,k=Object.keys(fields),l=k.length;i<l;i++){
        gw.params[k[i]]=fields[k[i]];
      }
      gw.files = files;
      callback();
    })
  ;
  upload.parse(gw.req);
}
333135
def init_chunked_upload
      headers = {
        'x-ton-content-type'   => content_type,
        'x-ton-content-length' => @file_size,
        'x-ton-expires'        => DEFAULT_EXPIRE,
        'content-length'       => 0,
        'content-type'         => content_type
      }
      resource = "#{DEFAULT_RESOURCE}#{@bucket}?resumable=true"
      TwitterAds::Request.new(
        @client, :post, resource, domain: DEFAULT_DOMAIN, headers: headers).perform
    end
639638
private void uploadPart() throws IOException {
    if (mFile == null) {
      return;
    }
    mLocalOutputStream.close();
    int partNumber = mPartNumber.getAndIncrement();
    File newFileToUpload = new File(mFile.getPath());
    mFile = null;
    mLocalOutputStream = null;
    UploadPartRequest uploadRequest = new UploadPartRequest()
        .withBucketName(mBucketName)
        .withKey(mKey)
        .withUploadId(mUploadId)
        .withPartNumber(partNumber)
        .withFile(newFileToUpload)
        .withPartSize(newFileToUpload.length());
    execUpload(uploadRequest);
  }
1094289
protected function uploadByChunks( $params ) {
		// Get the file handle for looping, but don't keep it in the request parameters.
		$fileHandle = $params['file'];
		unset( $params['file'] );
		// Track the chunks and offset.
		$chunksDone = 0;
		$params['offset'] = 0;
		while ( true ) {

			// 1. Make the request.
			$params['chunk'] = fread( $fileHandle, $this->chunkSize );
			$contentDisposition = 'form-data; name="chunk"; filename="' . $params['filename'] . '"';
			$request = MultipartRequest::factory()
				->setParams( $params )
				->setAction( 'upload' )
				->setMultipartParams( [
					'chunk' => [ 'headers' => [ 'Content-Disposition' => $contentDisposition ] ],
				] );
			$response = $this->api->postRequest( $request );

			// 2. Deal with the response.
			$chunksDone++;
			$params['offset'] = ( $chunksDone * $this->chunkSize );
			if ( !isset( $response['upload']['filekey'] ) ) {
				// This should never happen. Even the last response still has the filekey.
				throw new Exception( 'Unable to get filekey for chunked upload' );
			}
			$params['filekey'] = $response['upload']['filekey'];
			if ( $response['upload']['result'] === 'Continue' ) {
				// Amend parameters for next upload POST request.
				$params['offset'] = $response['upload']['offset'];
			} else {
				// The final upload POST will be done in self::upload()
				// to commit the upload out of the stash area.
				unset( $params['chunk'], $params['offset'] );
				return $params;
			}
		}
	}
289552
function hotDownloadUpdateChunk(chunkId) {
		var filename = require("path").join(__dirname, $hotChunkFilename$);
		require("fs").readFile(filename, "utf-8", function(err, content) {
			if (err) {
				if ($require$.onError) return $require$.oe(err);
				throw err;
			}
			var chunk = {};
			require("vm").runInThisContext(
				"(function(exports) {" + content + "\n})",
				{ filename: filename }
			)(chunk);
			hotAddUpdateChunk(chunk.id, chunk.modules);
		});
	}
330479
function createMultipartUpload(details) {
    cachedClient.createMultipartUpload(details, function (err, data) {
      if (err) return abortUpload(err);
      multipartUploadID = data.UploadId;
      multipartUploadResult = data;
      e.emit('ready');
    });
  }
978059
function(id) {
            var size = options.getSize(id),
                name = options.getName(id);

            log("All chunks have been uploaded for " + id + " - finalizing....");
            handler.finalizeChunks(id).then(
                function(response, xhr) {
                    log("Finalize successful for " + id);

                    var normaizedResponse = upload.normalizeResponse(response, true);

                    options.onProgress(id, name, size, size);
                    handler._maybeDeletePersistedChunkData(id);
                    upload.cleanup(id, normaizedResponse, xhr);
                },
                function(response, xhr) {
                    var normalizedResponse = upload.normalizeResponse(response, false);

                    log("Problem finalizing chunks for file ID " + id + " - " + normalizedResponse.error, "error");

                    if (
                        normalizedResponse.reset ||
                        (xhr && options.chunking.success.resetOnStatus.indexOf(xhr.status) >= 0)
                    ) {
                        chunked.reset(id);
                    }

                    if (!options.onAutoRetry(id, name, normalizedResponse, xhr)) {
                        upload.cleanup(id, normalizedResponse, xhr);
                    }
                }
            );
        }
565153
def upload(key, io, checksum: nil, **options)
      each_service.collect do |service|
        service.upload key, io.tap(&:rewind), checksum: checksum, **options
      end
    end
457245
CompleteMultipartUploadResult uploadObject(final UploadObjectRequest req)
            throws IOException, InterruptedException, ExecutionException {
        // Set up the pipeline for concurrent encrypt and upload
        // Set up a thread pool for this pipeline
        ExecutorService es = req.getExecutorService();
        final boolean defaultExecutorService = es == null;
        if (es == null)
            es = Executors.newFixedThreadPool(clientConfiguration.getMaxConnections());
        UploadObjectObserver observer = req.getUploadObjectObserver();
        if (observer == null)
            observer = new UploadObjectObserver();
        // initialize the observer
        observer.init(req, this, this, es);
        // Initiate upload
        observer.onUploadInitiation(req);
        final List<PartETag> partETags = new ArrayList<PartETag>();
        MultiFileOutputStream mfos = req.getMultiFileOutputStream();
        if (mfos == null)
            mfos = new MultiFileOutputStream();
        try {
            // initialize the multi-file output stream
            mfos.init(observer, req.getPartSize(), req.getDiskLimit());
            // Kicks off the encryption-upload pipeline;
            // Note mfos is automatically closed upon method completion.
            putLocalObject(req, mfos);
            // block till all part have been uploaded
            for (Future<UploadPartResult> future: observer.getFutures()) {
                UploadPartResult partResult = future.get();
                partETags.add(new PartETag(partResult.getPartNumber(), partResult.getETag()));
            }
        } finally {
            if (defaultExecutorService)
                es.shutdownNow();   // shut down the locally created thread pool
            mfos.cleanup();       // delete left-over temp files
        }
        // Complete upload
        return observer.onCompletion(partETags);
    }
691658
private String initMultipartUpload(String bucketName, String objectName, Map<String, String> headerMap)
    throws InvalidBucketNameException, NoSuchAlgorithmException, InsufficientDataException, IOException,
           InvalidKeyException, NoResponseException, XmlPullParserException, ErrorResponseException,
           InternalException {
    // set content type if not set already
    if (headerMap.get("Content-Type") == null) {
      headerMap.put("Content-Type", "application/octet-stream");
    }

    Map<String,String> queryParamMap = new HashMap<>();
    queryParamMap.put("uploads", "");

    HttpResponse response = executePost(bucketName, objectName, headerMap, queryParamMap, "");

    InitiateMultipartUploadResult result = new InitiateMultipartUploadResult();
    result.parseXml(response.body().charStream());
    response.body().close();
    return result.uploadId();
  }
1017752
def upload_bytes_per_chunk(self):
        
        value = self.values.get(Config.UPLOAD_BYTES_PER_CHUNK, DDS_DEFAULT_UPLOAD_CHUNKS)
        return Config.parse_bytes_str(value)
816697
def upload_simple(filename, overwrite:, target_name:)
      target_file = get(target_name)
      exist = target_file.file?
      return if exist && !overwrite
      path = nil
      if exist
        path = "#{target_file.api_path}/content"
      else
        path = "#{api_path}:/#{target_name}:/content"
      end

      query = {
        path: File.join('v1.0/me/', path),
        headers: {
          'Authorization': "Bearer #{@od.access_token.token}",
          'Content-Type': 'application/octet-stream'
        },
        body: File.read(filename)
      }
      result = @od.conn.put(query)
      result = JSON.parse(result.body)
      file = OneDriveFile.new(@od, result)
      file.set_mtime(File.mtime(filename))
    end
1176378
def upload(self, thread_uuid, file_path, description=None):
        
        url = "threads/%s/entries" % thread_uuid
        return self.core.upload(file_path, url, description)
539299
def _flush(self):
        
        # Initialize multipart upload
        if self._upload_id is None:
            with _handle_oss_error():
                self._upload_id = self._bucket.init_multipart_upload(
                    self._key).upload_id

        # Upload part with workers
        response = self._workers.submit(
            self._bucket.upload_part, key=self._key, upload_id=self._upload_id,
            part_number=self._seek, data=self._get_buffer().tobytes())

        # Save part information
        self._write_futures.append(
            dict(response=response, part_number=self._seek))
798892
def do_upload(post_data, callback=None):
    

    encoder = MultipartEncoder(post_data)
    monitor = MultipartEncoderMonitor(encoder, callback)

    headers = {'User-Agent': USER_AGENT, 'Content-Type': monitor.content_type}
    response = post(API_URL, data=monitor, headers=headers)
    check_response(response)

    return response.json()[0]