Upload from an URL
488786
def upload_url(url, options = {})
      params = upload_params(options).for_url_upload(url)
      token = request_file_upload(params)

      upload_status = poll_upload_result(token)
      if upload_status['status'] == 'error'
        raise ArgumentError.new(upload_status['error'])
      end

      Uploadcare::Api::File.new(self, upload_status['file_id'])
    end
76284
def build_upload_params(file_path, outputformat, callback_url = nil, options = {})
      upload_params = { :format => outputformat}
      upload_params.merge!(:callback => callback(callback_url)) if callback(callback_url).present?
      upload_params.merge!(:input => "download",:link => file_path )
      upload_params.merge!(options)
    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)
1155708
def copy_image_from_url(url, cache_dir=None, use_cache=True):
    
    return cache_image_data(cache_dir, hashlib.sha1(url).hexdigest(), ImgurUploader().upload, url, use_cache=use_cache)
124368
function(url, options, fn){
        var r = request.post(url, fn);
        var form = r.form();
        form.append('field', options.field);
        form.append('files', fs.createReadStream(options.filepath));
        return form;
    }
997933
def upload(cookie, source_path, path, upload_mode):
    '''
    '''
    ondup = const.UPLOAD_ONDUP[upload_mode]
    dir_name, file_name = os.path.split(path)
    url = ''.join([
        const.PCS_URL_C,
        'file?method=upload&app_id=250528',
        '&ondup=', ondup,
        '&dir=', encoder.encode_uri_component(dir_name),
        '&filename=', encoder.encode_uri_component(file_name),
        '&', cookie.sub_output('BDUSS'),
    ])
    with open(source_path, 'rb') as fh:
        data = fh.read()
    fields = []
    files = [('file', file_name, data)]
    headers = {'Accept': const.ACCEPT_HTML, 'Origin': const.PAN_URL}
    req = net.post_multipart(url, headers, fields, files)
    if req:
        return json.loads(req.data.decode())
    else:
        return None
1308665
def post(url, data=None, json=None, **kwargs):
    """"""
    _set_content_type(kwargs)
    if _content_type_is_json(kwargs) and data is not None:
        data = dumps(data)
    _log_request('POST', url, kwargs, data)
    response = requests.post(url, data, json, **kwargs)
    _log_response(response)
    return response
1129657
def upload(self):
        '''
        
        '''
        if not self.exists():
            self.create()

        data = self.stage().json()
        self.file_upload(data['post_url'], data)
        res = self.commit(data['dist_id'])
        data = res.json()
        return data
850169
def _post(self, url, params, uploads=None):
        
        self._call(self.POST, url, params, uploads)
623162
function upload($r, $param)
    {
        $this->setUp($param);

        if (isset($_FILES['files']['error'][0])
            && $_FILES['files']['error'][0] == UPLOAD_ERR_OK) {
            $name = basename($_FILES["files"]["name"][0]);

            $ext = explode('.', $name);
            $ext = '.'.end($ext);

            $name = md5($name);

            $a['files'][0] = [
               'name' => $name.$ext,
               'size' => $_FILES['files']['size'][0],
               'type' => $_FILES['files']['type'][0],
               'url'  => _URL.$this->articlePatch.$name.$ext];

            //Create a directory (if not exists)
            \Devbr\Cli\Main::checkAndOrCreateDir(_WWW.$this->articlePatch, true);

            //Save uploaded file
            move_uploaded_file($_FILES["files"]["tmp_name"][0], _WWW.$this->articlePatch.$name.$ext);

            //Resize image
            $canvas = new \Devbr\Canvas(_WWW.$this->articlePatch.$name.$ext);
            $canvas->set_quality(80)
                   ->resize('540')
                   ->save(_WWW.$this->articlePatch.$name.$ext);
            //Thumbnail
            $canvas->set_rgb('#000')
                   ->set_quality(70)
                   //->resize('265', '150', 'fill')
                   ->resize('120', '68', 'fill')
                   ->save(_WWW.$this->articlePatch.'mini_'.$name.$ext);

            //Send to javascript
            $this->send($a);
        }

        header('HTTP/1.1 403 Forbidden');
        exit();
    }
1261621
function uploadFile(file) {
  var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _lodash2.default.noop;

  // const upload = new Upload(file);
  // upload.on('end', res => {
  //   console.log(res);
  // });
  // const options = {
  //   path: window.UPLOAD_PATH || '/api/uploads/',
  // };
  // upload.to(options);

  // Create a new tus upload
  var upload = new _tusJsClient2.default.Upload(file, {
    // TODO enable resumable uploads
    resume: false,
    endpoint: window.UPLOAD_PATH || '/api/uploads/',
    onError: function onError(err) {
      console.log('upload failed:', err);
      callback(null, err);
    },
    onProgress: function onProgress(bytesUploaded, bytesTotal) {
      var percentage = (bytesUploaded / bytesTotal * 100).toFixed(2);
      console.log('progress %s/%s, %s', bytesUploaded, bytesTotal, percentage + '%');
    },
    onSuccess: function onSuccess() {
      console.log('download %s from %s', upload.file.name, upload.url);
      callback({ name: upload.file.name, url: upload.url });
    }
  });

  // Start the upload
  upload.start();
}
45305
def post_image(url, filename)
      post(url) do |req|
        req.body = open(filename).read
      end
    end
555108
def upload(self, local_path, remote_url):
        """"""
        bucket, key = _parse_url(remote_url)

        with open(local_path, 'rb') as fp:
            return self.call("PutObject", bucket=bucket, key=key, body=fp)
608973
def upload_file(upload_url, upload_fields, filepath, callback=None):
    """"""
    upload_fields = list(six.iteritems(upload_fields))
    upload_fields.append(
        ("file", (os.path.basename(filepath), click.open_file(filepath, "rb")))
    )
    encoder = MultipartEncoder(upload_fields)
    monitor = MultipartEncoderMonitor(encoder, callback=callback)

    config = cloudsmith_api.Configuration()
    if config.proxy:
        proxies = {"http": config.proxy, "https": config.proxy}
    else:
        proxies = None

    headers = {"content-type": monitor.content_type}

    client = get_files_api()
    headers["user-agent"] = client.api_client.user_agent

    session = create_requests_session()
    resp = session.post(upload_url, data=monitor, headers=headers, proxies=proxies)

    try:
        resp.raise_for_status()
    except requests.RequestException as exc:
        raise ApiException(
            resp.status_code, headers=exc.response.headers, body=exc.response.content
        )
1063645
def upload_simple(self, fd, filename, folder_key=None, path=None,
                      filedrop_key=None, action_on_duplicate=None,
                      mtime=None, file_size=None, file_hash=None):
        
        action = 'upload/simple'

        params = QueryParams({
            'folder_key': folder_key,
            'path': path,
            'filedrop_key': filedrop_key,
            'action_on_duplicate': action_on_duplicate,
            'mtime': mtime
        })

        headers = QueryParams({
            'X-Filesize': str(file_size),
            'X-Filehash': file_hash,
            'X-Filename': filename.encode('utf-8')
        })

        upload_info = {
            "fd": fd,
        }

        return self.request(action, params, action_token_type="upload",
                            upload_info=upload_info, headers=headers)
725439
def from_file(self, fp):
        
        image_urls = self.upload(fp)
        return Image(image_urls['url'], source_url=image_urls['picture_url'])
204898
def file_upload(object_id, input_params={}, always_retry=True, **kwargs):
    
    return DXHTTPRequest('/%s/upload' % object_id, input_params, always_retry=always_retry, **kwargs)