Creates an upload for the given file or path.
331294
def create(self, file_or_path, **kwargs):
        

        opened = False
        if isinstance(file_or_path, str_type()):
            file_or_path = open(file_or_path, 'rb')
            opened = True
        elif not getattr(file_or_path, 'read', False):
            raise Exception("A file or path to a file is required for this operation.")

        try:
            return self.client._post(
                self._url(),
                file_or_path,
                headers=self._resource_class.create_headers({}),
                file_upload=True
            )
        finally:
            if opened:
                file_or_path.close()
372324
def upload(self, url, filename, data=None, formname=None,
               otherfields=()):
        
        if data is None:
            data = open(filename, 'rb')
        self._upbuffer = StringIO.StringIO(get_upload_form(filename, data,
                                                           formname,
                                                           otherfields))
        ulheaders = self.stdheaders.copy()
        ulheaders['Content-Type'] = 'multipart/form-data; boundary=' + BND
        ulheaders['Content-Length'] = len(uploadforms[filename])
        self.ulsize = len(uploadforms[filename])
        webclient = self.dupe()
        webclient.request('POST', url, self._upbuffer, ulheaders)
        rsp = webclient.getresponse()
        # peer updates in progress should already have pointers,
        # subsequent transactions will cause memory to needlessly double,
        # but easiest way to keep memory relatively low
        try:
            del uploadforms[filename]
        except KeyError:  # something could have already deleted it
            pass
        self.rspstatus = rsp.status
        if rsp.status != 200:
            raise Exception('Unexpected response in file upload: ' +
                            rsp.read())
        return rsp.read()
1176378
def upload(self, thread_uuid, file_path, description=None):
        
        url = "threads/%s/entries" % thread_uuid
        return self.core.upload(file_path, url, description)
1062405
function uploadFile(file, request, host) {
  return function(cb) {
    request
      .post(host + '/file/' + file.hash)
      .attach('data', file.abs)
      .end(function(err, res) {
        if (err) return cb(err);
        if (res.error) return cb(res.error);
        return cb();
      });
  };
}
337175
def param_upload(field, path):
    
    if not path:
        return None
    param = {}
    param['field'] = field
    param['path'] = path
    return param
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)
1336632
function create(path) {
  assert.string(path, 'path');
  let flags = 'wx+';
  return fsOpen(path, flags)
    .then(fd => fsStat(fd)
      .then(st => new RandomAccessFile(path, fd, st.size, true)));
}
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();
}
1037903
def file_upload(context, id, path):
    
    result = component.file_upload(context, id=id, file_path=path)
    utils.format_output(result, context.format)
1292432
public void addFile(String path, InputStream inputStream) throws IOException {
    addFile(path, inputStream, null);
  }
149423
def create_file(self, path, content, mode='w'):
        
        self._check_started()
        sftp = paramiko.SFTPClient.from_transport(self._transport)
        with sftp.open(path, mode) as remote_file:
            remote_file.write(content)
            remote_file.flush()
900260
def Upload(cls, filename):
        
        raise Exception("to do")
    
        TOOLS_PATH = ""
        RESOURCE_PATH = ""
        tool_4path = os.path.join(TOOLS_PATH, "upload.exe")        
        file_4path = os.path.join(RESOURCE_PATH, filename)
        #file_4path.decode('utf-8').encode('gbk')
        
        if os.path.isfile(file_4path):
            cls.Click()
            os.system(tool_4path + ' ' + file_4path)
        else:
            raise Exception('%s is not exists' % file_4path)
1220939
public boolean upload(String path, String fileName, File file) {
		try (InputStream in = FileUtil.getInputStream(file)) {
			return upload(path, fileName, in);
		} catch (IOException e) {
			throw new FtpException(e);
		}
	}
359218
def upload_file(self, real_file_path, file_name, dir_name=None):
        

        if dir_name is not None and dir_name[0] == '/':
            dir_name = dir_name[1:len(dir_name)]
        if dir_name is None:
            dir_name = ""
        self.url = 'http://' + self.config.region + '.file.myqcloud.com/files/v2/' + str(self.config.app_id) + '/' + self.config.bucket
        if dir_name is not None:
            self.url = self.url + '/' + dir_name
        self.url = self.url + '/' + file_name
        headers = {}
        headers['Authorization'] = CosAuth(self.config).sign_more(self.config.bucket, '', 30)
        files = {'file': ('', open(real_file_path, 'rb'))}
        r = requests.post(url=self.url, data={'op': 'upload', 'biz_attr': '', 'insertOnly': '0'}, files={
            'filecontent': (real_file_path, open(real_file_path, 'rb'), 'application/octet-stream')}, headers=headers)
        return str(eval(r.content.decode('utf8')).get('data'))
1284140
def upload(self, file_path, description=None, async=False):
        
        url = "documents?async={a}".format(a=async)
        return self.core.upload(file_path, url, description)
579636
def create(self, filename, filedata):
        """"""
        attributes = {'filename': filename,
                      'source': filedata}
        return self.transport.POST(url='/file/v2/', body=attributes, type='multipart/form-data')
735921
private void putFile(String name, UploadFile uploadFile) {
		UploadFile[] fileUploads = requestFiles.get(name);
		fileUploads = fileUploads == null ? new UploadFile[] { uploadFile } : ArrayUtil.append(fileUploads, uploadFile);
		requestFiles.put(name, fileUploads);
	}