CreateExtension.
        [Preview API]
        :param object upload_stream: Stream to upload
        :rtype: :class:`<PublishedExtension> <azure.devops.v5_1.gallery.models.PublishedExtension>`
501041
def create_extension(self, upload_stream, **kwargs):
        
        if "callback" in kwargs:
            callback = kwargs["callback"]
        else:
            callback = None
        content = self._client.stream_upload(upload_stream, callback=callback)
        response = self._send(http_method='POST',
                              location_id='a41192c8-9525-4b58-bc86-179fa549d80d',
                              version='5.1-preview.2',
                              content=content,
                              media_type='application/octet-stream')
        return self._deserialize('PublishedExtension', response)
489787
private <RequestT, ResponseT> ResponseT uploadObject(final InputStream originalStream,
                                                         final File file,
                                                         final ObjectMetadata metadata,
                                                         final ProgressListener listener,
                                                         final Request<RequestT> request,
                                                         final S3DataSource originalRequest,
                                                         final boolean skipServerSideValidation,
                                                         final boolean skipClientSideValidationPerRequest,
                                                         final UploadObjectStrategy<RequestT, ResponseT> uploadStrategy,
                                                         final boolean setContentTypeIfNotProvided) {

        InputStream input = getInputStream(originalStream, file, metadata, request,
                                           skipServerSideValidation, setContentTypeIfNotProvided);

        final ObjectMetadata returnedMetadata;
        MD5DigestCalculatingInputStream md5DigestStream = null;
        try {
            if (metadata.getContentMD5() == null && !skipClientSideValidationPerRequest) {
                /*
                 * If the user hasn't set the content MD5, then we don't want to buffer the whole
                 * stream in memory just to calculate it. Instead, we can calculate it on the fly
                 * and validate it with the returned ETag from the object upload.
                 */
                input = md5DigestStream = new MD5DigestCalculatingInputStream(input);
            }

            populateRequestMetadata(request, metadata);
            request.setContent(input);
            publishProgress(listener, ProgressEventType.TRANSFER_STARTED_EVENT);
            try {
                returnedMetadata = uploadStrategy.invokeServiceCall(request);
            } catch (Throwable t) {
                publishProgress(listener, ProgressEventType.TRANSFER_FAILED_EVENT);
                throw failure(t);
            }
        } finally {
            cleanupDataSource(originalRequest, file, originalStream, input, log);
        }

        String contentMd5 = metadata.getContentMD5();
        if (md5DigestStream != null) {
            contentMd5 = Base64.encodeAsString(md5DigestStream.getMd5Digest());
        }

        final String etag = returnedMetadata.getETag();
        if (contentMd5 != null && !skipMd5CheckStrategy.skipClientSideValidationPerPutResponse(returnedMetadata)) {
            byte[] clientSideHash = BinaryUtils.fromBase64(contentMd5);
            byte[] serverSideHash = BinaryUtils.fromHex(etag);

            if (!Arrays.equals(clientSideHash, serverSideHash)) {
                publishProgress(listener, ProgressEventType.TRANSFER_FAILED_EVENT);
                throw new SdkClientException(
                    "Unable to verify integrity of data upload. Client calculated content hash (contentMD5: " + contentMd5
                    + " in base 64) didn't match hash (etag: " + etag + " in hex) calculated by Amazon S3.  "
                    + "You may need to delete the data stored in Amazon S3. (metadata.contentMD5: " + metadata.getContentMD5()
                    + ", md5DigestStream: " + md5DigestStream
                    + uploadStrategy.md5ValidationErrorSuffix()
                    + ")");
            }
        }

        publishProgress(listener, ProgressEventType.TRANSFER_COMPLETED_EVENT);

        return uploadStrategy.createResult(returnedMetadata, contentMd5);
    }
1045362
def set_file_to_upload(self, file_to_upload):
        # type: (str) -> None
        
        if 'url' in self.data:
            del self.data['url']
        self.file_to_upload = file_to_upload
1016134
def create_stream(stream_name, num_shards, region=None, key=None, keyid=None, profile=None):
    '''
    
    '''
    conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
    r = _execute_with_retries(conn,
                              "create_stream",
                              ShardCount=num_shards,
                              StreamName=stream_name)
    if 'error' not in r:
        r['result'] = True
    return r
247766
public <T extends PushConnector> FutureData<PushSubscription> create(final T connector,
                                                                         Stream stream,
                                                                         final String name,
                                                                         final Status initialStatus,
                                                                         final long start,
                                                                         final long end) {
        return create(connector, null, FutureData.wrap(stream), name, initialStatus, start, end);
    }
595383
def run_upload(video_file_path):
    

    upload_parameters = {
        'file_path': video_file_path,
        'file_size': os.stat(video_file_path).st_size,
        'file_name': os.path.basename(video_file_path)
    }

    try:
        # Setup API client
        jwplatform_client = Client(JW_API_KEY, JW_API_SECRET)

        # Make /videos/create API call with multipart parameter specified
        jwplatform_video_create_response = jwplatform_client.videos.create(
            upload_method='multipart',
            title=upload_parameters['file_name']
        )

    except JWPlatformError:
        logging.exception('An error occurred during the uploader setup. Check that your API keys are properly '
                          'set up in your environment, and ensure that the video file path exists.')
        return

    # Construct base url for upload
    upload_parameters['upload_url'] = '{protocol}://{address}{path}'.format(**jwplatform_video_create_response['link'])

    logging.info('Upload URL to be used: {}'.format(upload_parameters['upload_url']))

    upload_parameters['query_parameters'] = jwplatform_video_create_response['link']['query']
    upload_parameters['query_parameters']['api_format'] = 'json'
    upload_parameters['headers'] = {'X-Session-ID': jwplatform_video_create_response['session_id']}
    # The chunk offset will be updated several times during the course of the upload
    upload_parameters['chunk_offset'] = 0

    # Perform the multipart upload
    with open(upload_parameters['file_path'], 'rb') as file_to_upload:
        while True:
            chunk = file_to_upload.read(BYTES_TO_BUFFER)
            if len(chunk) <= 0:
                break

            try:
                upload_chunk(chunk, upload_parameters)

            # Log any exceptions that bubbled up
            except requests.exceptions.RequestException:
                logging.exception('Error posting data, stopping upload...')
                break
1176378
def upload(self, thread_uuid, file_path, description=None):
        
        url = "threads/%s/entries" % thread_uuid
        return self.core.upload(file_path, url, description)
201109
private void uploadStream() throws SnowflakeSQLException
  {
    try
    {
      threadExecutor = SnowflakeUtil.createDefaultExecutorService(
          "sf-stream-upload-worker-", 1);

      RemoteStoreFileEncryptionMaterial encMat = encryptionMaterial.get(0);
      if (commandType == CommandType.UPLOAD)
      {
        threadExecutor.submit(getUploadFileCallable(
            stageInfo, SRC_FILE_NAME_FOR_STREAM,
            fileMetadataMap.get(SRC_FILE_NAME_FOR_STREAM),
            (stageInfo.getStageType() == StageInfo.StageType.LOCAL_FS) ?
            null : storageFactory.createClient(stageInfo, parallel, encMat),
            connection, command,
            sourceStream, true, parallel, null, encMat));
      }
      else if (commandType == CommandType.DOWNLOAD)
      {
        throw new SnowflakeSQLException(SqlState.INTERNAL_ERROR,
                                        ErrorCode.INTERNAL_ERROR.getMessageCode());
      }

      threadExecutor.shutdown();

      try
      {
        // wait for all threads to complete without timeout
        threadExecutor.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS);
      }
      catch (InterruptedException ex)
      {
        throw new SnowflakeSQLException(SqlState.QUERY_CANCELED,
                                        ErrorCode.INTERRUPTED.getMessageCode());
      }
      logger.debug("Done with uploading from a stream");
    }
    finally
    {
      if (threadExecutor != null)
      {
        threadExecutor.shutdownNow();
        threadExecutor = null;
      }
    }
  }
1351353
function (file, callback) {

                var self = this,
                    reader = new FileReader();

                var uploadDesign = this.$.imageUploadService.upload(file, function (err) {
                    if (!err) {
                        self.trigger("uploadComplete", {
                            uploadDesign: uploadDesign
                        });
                    } else {
                        self.trigger("uploadError", {
                            error: err,
                            uploadDesign: uploadDesign
                        });
                    }

                    callback && callback(err, uploadDesign);
                });

                reader.onload = function(evt) {

                    var img = new Image();
                    img.onload = function() {
                        uploadDesign.set({
                            previewImage: evt.target.result,
                            localImage: evt.target.result
                        });
                    };
                    img.src = evt.target.result;
                };

                reader.readAsDataURL(file);


                return uploadDesign;
            }
77924
def send(self, stream_to_file=None):
        
        try:
            self._stage = STAGE_REQUEST
            self.prepared_request.prepare(method=self.method,
                                          url=self.endpoint_url,
                                          files=self.files,
                                          json=self.json,
                                          data=self.data,
                                          headers=self.headers,
                                          params=self.params,
                                          cookies=self.cookies,
                                          hooks=self.hooks)

        except Exception as e1:
            self.error = ApiError(
                "Exception in making Request with:: %s\n%s" % (
                    e1, traceback.format_exc()))
            raise Exception(self.error)

        try:
            self._stage = STAGE_SENDING
            self._timestamps['send'] = time.time()
            self.response = self.session.send(self.prepared_request,
                                              proxies=self.proxies,
                                              timeout=self.timeout,
                                              stream=bool(stream_to_file),
                                              verify=VERIFY,
                                              cert=None)
            self._stage = STAGE_RESPONDING
            self._timestamps['receive'] = time.time()
        except Exception as e2:
            self._timestamps.setdefault('exception', time.time())
            self.error = e2
            raise

        self.post_process(stream_to_file)
        self._stage = ((self.name == 'Unknown') and
                       STAGE_DONE_DATA_FORMATTED or STAGE_DONE)
        return self.data
822346
def _create_stream(self, max_buffer_size, af, addr, **kwargs):  # pylint: disable=unused-argument
        '''
        
        '''
        # Always connect in plaintext; we'll convert to ssl if necessary
        # after one connection has completed.
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        _set_tcp_keepalive(sock, self.opts)
        stream = tornado.iostream.IOStream(
            sock,
            max_buffer_size=max_buffer_size)
        if tornado.version_info < (5,):
            return stream.connect(addr)
        return stream, stream.connect(addr)
595305
def load_collection_from_stream(resource, stream, content_type):
    
    coll = create_staging_collection(resource)
    load_into_collection_from_stream(coll, stream, content_type)
    return coll
988534
def _add_to_upload_queue(self, src, rfile, uid):
        # type: (Uploader, blobxfer.models.upload.LocalPath,
        #        blobxfer.models.azure.StorageEntity, str) -> None
        
        # prepare local file for upload
        ud = blobxfer.models.upload.Descriptor(
            src, rfile, uid, self._spec.options, self._general_options,
            self._resume)
        if ud.entity.is_encrypted:
            with self._upload_lock:
                self._ud_map[uid] = ud
        # add download descriptor to queue
        self._upload_queue.put(ud)
        if self._upload_start_time is None:
            with self._upload_lock:
                if self._upload_start_time is None:
                    self._upload_start_time = blobxfer.util.datetime_now()
220939
def upload_file(self, file_name, file_obj, *args, **kwargs):
		
		self.dav_client().upload_to(file_obj, self.join_path(self.session_path(), file_name))
234777
function create(filePath, maxSize, cb) {
  createStream(filePath, onHaveStream);

  function onHaveStream(err, stream, size) {
    if (err) return cb(err);
    var pending = null;
    var log = new EventEmitter();
    stream.on('error', function(err) {
      log.emit('error', err);
    });
    log.write = logWrite;
    cb(null, log);
    function logWrite(str) {
      var flushed = stream.write(str);
      size += str.length;
      if (pending === 'flush') {
        if (flushed) {
          pending = null;
        } else {
          stream.once('drain', function() {
            pending = null;
          });
        }
      }
      if (pending == null && size >= maxSize) {
        pending = 'rename';
        var archiveName = getArchiveName(filePath);
        fs.rename(filePath, archiveName, function(err){
          if (err) return log.emit('error', err);
          createStream(filePath, function(err, newStream, newSize){
            if (err) return log.emit('error', err);
            stream.once('close', function() {
              var gzip = zlib.createGzip();
              var inp = fs.createReadStream(archiveName);
              var out = fs.createWriteStream(archiveName + ".gz");
              inp.on('error', function(err) {
                return log.emit('error', err);
              });
              out.on('error', function(err){
                return log.emit('error', err);
              });
              inp.pipe(gzip).pipe(out);
              out.once('close', function(){
                fs.unlink(archiveName, function(err){
                  if (err) return log.emit('error', err);
                });
              });
            });
            stream.end();
            newStream.on('error', function(err) {
              return log.emit('error', err);
            });
            size = newSize;
            stream = newStream;
            pending = 'flush';
          });
        });
      }
    }
  }
}
747361
private static void createDeliveryStream() throws Exception {

        boolean deliveryStreamExists = false;

        LOG.info("Checking if " + deliveryStreamName + " already exits");
        List<String> deliveryStreamNames = listDeliveryStreams();
        if (deliveryStreamNames != null && deliveryStreamNames.contains(deliveryStreamName)) {
            deliveryStreamExists = true;
            LOG.info("DeliveryStream " + deliveryStreamName + " already exists. Not creating the new delivery stream");
        } else {
            LOG.info("DeliveryStream " + deliveryStreamName + " does not exist");
        }

        if (!deliveryStreamExists) {
            // Create DeliveryStream
            CreateDeliveryStreamRequest createDeliveryStreamRequest = new CreateDeliveryStreamRequest();
            createDeliveryStreamRequest.setDeliveryStreamName(deliveryStreamName);

            S3DestinationConfiguration redshiftS3Configuration = new S3DestinationConfiguration();
            redshiftS3Configuration.setBucketARN(s3BucketARN);
            redshiftS3Configuration.setPrefix(s3ObjectPrefix);

            BufferingHints bufferingHints = null;
            if (s3DestinationSizeInMBs != null || s3DestinationIntervalInSeconds != null) {
                bufferingHints = new BufferingHints();
                bufferingHints.setSizeInMBs(s3DestinationSizeInMBs);
                bufferingHints.setIntervalInSeconds(s3DestinationIntervalInSeconds);
            }
            redshiftS3Configuration.setBufferingHints(bufferingHints);

            // Create and set IAM role so that firehose service has access to the S3Buckets to put data. 
            // Please check the trustPolicyDocument.json and permissionsPolicyDocument.json files 
            // for the trust and permissions policies set for the role.
            String iamRoleArn = createIamRole(s3ObjectPrefix);
            redshiftS3Configuration.setRoleARN(iamRoleArn);
            
            CopyCommand copyCommand = new CopyCommand();
            copyCommand.withCopyOptions(copyOptions)
                .withDataTableName(dataTableName);
            
            RedshiftDestinationConfiguration redshiftDestinationConfiguration = new RedshiftDestinationConfiguration();
            redshiftDestinationConfiguration.withClusterJDBCURL(clusterJDBCUrl)
                .withRoleARN(iamRoleArn)
                .withUsername(username)
                .withPassword(password)
                .withCopyCommand(copyCommand)
                .withS3Configuration(redshiftS3Configuration);
            
            createDeliveryStreamRequest.setRedshiftDestinationConfiguration(redshiftDestinationConfiguration);

            firehoseClient.createDeliveryStream(createDeliveryStreamRequest);

            // The Delivery Stream is now being created.
            LOG.info("Creating DeliveryStream : " + deliveryStreamName);
            waitForDeliveryStreamToBecomeAvailable(deliveryStreamName);
        }
    }
901914
def create_upload_url_async(success_path,
                            max_bytes_per_blob=None,
                            max_bytes_total=None,
                            **options):
  """"""
  rpc = blobstore.create_rpc(**options)
  rpc = blobstore.create_upload_url_async(success_path,
                                          max_bytes_per_blob=max_bytes_per_blob,
                                          max_bytes_total=max_bytes_total,
                                          rpc=rpc)
  result = yield rpc
  raise tasklets.Return(result)