Integrity-Check and Commit a ChunkedUpload, readying it for use elsewhere.

@param accountId The external account number (int) or account ID Guid. (required)
@param chunkedUploadId  (required)
@return ChunkedUploadResponse
504177
public ChunkedUploadResponse updateChunkedUpload(String accountId, String chunkedUploadId) throws ApiException {
    return updateChunkedUpload(accountId, chunkedUploadId, null);
  }
463
def account_block(self, id):
        
        id = self.__unpack_id(id)
        url = '/api/v1/accounts/{0}/block'.format(str(id))
        return self.__api_request('POST', url)
451058
private <E extends Throwable> HttpRequestor.Response chunkedUploadCommon(String[] params, long chunkSize, DbxStreamWriter<E> writer)
        throws DbxException, E
    {
        String apiPath = "1/chunked_upload";

        ArrayList<HttpRequestor.Header> headers = new ArrayList<HttpRequestor.Header>();
        headers.add(new HttpRequestor.Header("Content-Type", "application/octet-stream"));
        headers.add(new HttpRequestor.Header("Content-Length", Long.toString(chunkSize)));

        HttpRequestor.Uploader uploader = DbxRequestUtil.startPut(requestConfig, accessToken, USER_AGENT_ID, host.getContent(), apiPath, params, headers);
        try {
            NoThrowOutputStream nt = new NoThrowOutputStream(uploader.getBody());
            try {
                // Any exceptions thrown by writer.write (e.g. IOException) are "owned" by
                // the caller so let them propagate.  We should only handle exceptions caused
                // by our uploader OutputStream.
                writer.write(nt);
            }
            catch (NoThrowOutputStream.HiddenException ex) {
                if (ex.owner == nt) throw new NetworkIOException(ex.getCause());
                throw ex;
            }

            long bytesWritten = nt.getBytesWritten();
            if (bytesWritten != chunkSize) {
                throw new IllegalStateException("'chunkSize' is " + chunkSize + ", but 'writer' only wrote " + bytesWritten + " bytes");
            }

            try {
                return uploader.finish();
            }
            catch (IOException ex) {
                throw new NetworkIOException(ex);
            }
        }
        finally {
            uploader.close();
        }
    }
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);
                    }
                }
            );
        }
699622
public int getChunkForKey(byte[] key) throws IllegalStateException {
        if(numChunks == 0) {
            throw new IllegalStateException("The ChunkedFileSet is closed.");
        }

        switch(storageFormat) {
            case READONLY_V0: {
                return ReadOnlyUtils.chunk(ByteUtils.md5(key), numChunks);
            }
            case READONLY_V1: {
                if(nodePartitionIds == null) {
                    throw new IllegalStateException("nodePartitionIds is null.");
                }
                List<Integer> routingPartitionList = routingStrategy.getPartitionList(key);
                routingPartitionList.retainAll(nodePartitionIds);

                if(routingPartitionList.size() != 1) {
                    throw new IllegalStateException("The key does not belong on this node.");
                }

                return chunkIdToChunkStart.get(routingPartitionList.get(0))
                       + ReadOnlyUtils.chunk(ByteUtils.md5(key),
                                             chunkIdToNumChunks.get(routingPartitionList.get(0)));
            }
            case READONLY_V2: {
                List<Integer> routingPartitionList = routingStrategy.getPartitionList(key);

                Pair<Integer, Integer> bucket = null;
                for(int replicaType = 0; replicaType < routingPartitionList.size(); replicaType++) {
                    if(nodePartitionIds == null) {
                        throw new IllegalStateException("nodePartitionIds is null.");
                    }
                    if(nodePartitionIds.contains(routingPartitionList.get(replicaType))) {
                        if(bucket == null) {
                            bucket = Pair.create(routingPartitionList.get(0), replicaType);
                        } else {
                            throw new IllegalStateException("Found more than one replica for a given partition on the current node!");
                        }
                    }
                }

                if(bucket == null) {
                    throw new IllegalStateException("The key does not belong on this node.");
                }

                Integer chunkStart = chunkIdToChunkStart.get(bucket);

                if (chunkStart == null) {
                    throw new IllegalStateException("chunkStart is null.");
                }

                return chunkStart + ReadOnlyUtils.chunk(ByteUtils.md5(key), chunkIdToNumChunks.get(bucket));
            }
            default: {
                throw new IllegalStateException("Unsupported storageFormat: " + storageFormat);
            }
        }

    }
858048
private function registerChunkAsync($uploadRequestInfo, $chunkNumber)
    {
        $s3Filename = sprintf("%s/p%d", $uploadRequestInfo['s3_filename'], $chunkNumber);

        $data = [
            'id' => $uploadRequestInfo['s3file']['uploadid'],
            'targetid' => $uploadRequestInfo['s3file']['targetid'],
            'filename' => $s3Filename,
            'chunkNumber' => $chunkNumber,
        ];
        return $this->requestHandler->sendRequestAsync(
            'POST',
            sprintf('api/v4/upload/%s/', $uploadRequestInfo['s3file']['uploadid']),
            ['form_params' => $data]
        );
    }
191106
@Override
    public void checkOut(String repositoryId, Holder<String> objectId, ExtensionsData extension,
            Holder<Boolean> contentCopied) {

        jcrRepository(repositoryId).checkOut(login(repositoryId), objectId, contentCopied);
    }
1309082
def __upload_chunk(self, resource, chunk_size, bytes, bytes_start, bytes_read):
        """"""

        # note: string conversion required here due to open encoding bug in requests-oauthlib.
        headers = {
            'content-type': self.content_type,
            'content-length': str(min([chunk_size, self._file_size - bytes_read])),
            'content-range': "bytes {0}-{1}/{2}".format(
                bytes_start, bytes_read - 1, self._file_size)
        }

        return Request(self._client, 'put', resource,
                       domain=self._DEFAULT_DOMAIN, headers=headers, body=bytes).perform()
1119950
public <E extends Throwable> DbxEntry.File uploadFileChunked(String targetPath, DbxWriteMode writeMode, long numBytes, DbxStreamWriter<E> writer)
        throws DbxException, E
    {
        Uploader uploader = startUploadFileChunked(targetPath, writeMode, numBytes);
        return finishUploadFile(uploader, writer);
    }
567152
function(id, dontAllowNext) {
            var allowNext = !dontAllowNext,
                waitingIndex = qq.indexOf(connectionManager._waiting, id),
                connectionsIndex = qq.indexOf(connectionManager._open, id),
                nextId;

            delete connectionManager._openChunks[id];

            if (upload.getProxyOrBlob(id) instanceof qq.BlobProxy) {
                log("Generated blob upload has ended for " + id + ", disposing generated blob.");
                delete handler._getFileState(id).file;
            }

            // If this file was not consuming a connection, it was just waiting, so remove it from the waiting array
            if (waitingIndex >= 0) {
                connectionManager._waiting.splice(waitingIndex, 1);
            }
            // If this file was consuming a connection, allow the next file to be uploaded
            else if (allowNext && connectionsIndex >= 0) {
                connectionManager._open.splice(connectionsIndex, 1);

                nextId = connectionManager._waiting.shift();
                if (nextId >= 0) {
                    connectionManager._open.push(nextId);
                    upload.start(nextId);
                }
            }
        }
1202074
def _upload(self, obj_name, content, content_type, content_encoding,
            content_length, etag, chunked, chunk_size, headers):
        
        if content_type is not None:
            headers["Content-Type"] = content_type
        if content_encoding is not None:
            headers["Content-Encoding"] = content_encoding
        if isinstance(content, six.string_types):
            fsize = len(content)
        else:
            if chunked:
                fsize = None
            elif content_length is None:
                fsize = get_file_size(content)
            else:
                fsize = content_length
        if fsize is None or fsize <= MAX_FILE_SIZE:
            # We can just upload it as-is.
            return self._store_object(obj_name, content=content, etag=etag,
                    chunked=chunked, chunk_size=chunk_size, headers=headers)
        # Files larger than MAX_FILE_SIZE must be segmented
        # and uploaded separately.
        num_segments = int(math.ceil(float(fsize) / MAX_FILE_SIZE))
        digits = int(math.log10(num_segments)) + 1
        # NOTE: This could be greatly improved with threading or other
        # async design.
        for segment in range(num_segments):
            sequence = str(segment + 1).zfill(digits)
            seg_name = "%s.%s" % (obj_name, sequence)
            with utils.SelfDeletingTempfile() as tmpname:
                with open(tmpname, "wb") as tmp:
                    tmp.write(content.read(MAX_FILE_SIZE))
                with open(tmpname, "rb") as tmp:
                    # We have to calculate the etag for each segment
                    etag = utils.get_checksum(tmp)
                    self._store_object(seg_name, content=tmp, etag=etag,
                            chunked=False, headers=headers)
        # Upload the manifest
        headers.pop("ETag", "")
        headers["X-Object-Manifest"] = "%s/%s." % (self.name, obj_name)
        self._store_object(obj_name, content=None, headers=headers)
428481
public static int getChunkId(String fileName) {
        Pattern pattern = Pattern.compile("_[\\d]+\\.");
        Matcher matcher = pattern.matcher(fileName);

        if(matcher.find()) {
            return new Integer(fileName.substring(matcher.start() + 1, matcher.end() - 1));
        } else {
            throw new VoldemortException("Could not extract out chunk id from " + fileName);
        }
    }
751649
public GetIndividualProfilesRequest withIndividualId(final int id) {
        this.id = id;
        this.password = new char[0];
        this.login = this.accountNumber = this.routingNumber = null;
        return this;
    }
1248112
@RequestMapping(value = "{accountId}", method = RequestMethod.DELETE)
    public Ack deleteAccount(@PathVariable ID accountId) {
        return accountService.deleteAccount(accountId);
    }
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
939298
@Override
    public int numChunksSoFar(String id) {
        if (!chunks.containsKey(id))
            return 0;
        return chunks.get(id).size();
    }
112143
private void startMultipartUpload(WebContext ctx, Bucket bucket, String id) {
        Response response = ctx.respondWith();

        Map<String, String> properties = Maps.newTreeMap();
        for (String name : ctx.getRequest().headers().names()) {
            String nameLower = name.toLowerCase();
            if (nameLower.startsWith("x-amz-meta-") || "content-md5".equals(nameLower) || "content-type".equals(
                    nameLower) || "x-amz-acl".equals(nameLower)) {
                properties.put(name, ctx.getHeader(name));
                response.addHeader(name, ctx.getHeader(name));
            }
        }
        response.setHeader(HTTP_HEADER_NAME_CONTENT_TYPE, CONTENT_TYPE_XML);

        String uploadId = String.valueOf(uploadIdCounter.inc());
        multipartUploads.add(uploadId);

        getUploadDir(uploadId).mkdirs();

        XMLStructuredOutput out = response.xml();
        out.beginOutput("InitiateMultipartUploadResult");
        out.property(RESPONSE_BUCKET, bucket.getName());
        out.property("Key", id);
        out.property("UploadId", uploadId);
        out.endOutput();
    }