prepare to upload topology jar, return the file location
192157
@Override
    public String beginFileUpload() throws TException {
        String fileLoc = null;
        try {
            String path;
            String key = UUID.randomUUID().toString();
            path = StormConfig.masterInbox(conf) + "/" + key;
            FileUtils.forceMkdir(new File(path));
            FileUtils.cleanDirectory(new File(path));
            fileLoc = path + "/stormjar-" + key + ".jar";

            data.getUploaders().put(fileLoc, Channels.newChannel(new FileOutputStream(fileLoc)));
            LOG.info("Begin upload file from client to " + fileLoc);
            return path;
        } catch (FileNotFoundException e) {
            LOG.error("File not found: " + fileLoc, e);
            throw new TException(e);
        } catch (IOException e) {
            LOG.error("Upload file error: " + fileLoc, e);
            throw new TException(e);
        }
    }
1251098
def _copy(self, filename, id_=-1, file_type=0):
        
        if os.path.isdir(filename):
            raise JSSUnsupportedFileType(
                "Distribution Server type repos do not permit directory "
                "uploads. You are probably trying to upload a non-flat "
                "package. Please zip or create a flat package.")
        basefname = os.path.basename(filename)
        resource = open(filename, "rb")
        headers = {"DESTINATION": self.destination, "OBJECT_ID": str(id_),
                   "FILE_TYPE": file_type, "FILE_NAME": basefname}
        response = self.connection["jss"].session.post(
            url=self.connection["upload_url"], data=resource, headers=headers)
        if self.connection["jss"].verbose:
            print response
1281866
def _set_upload_url(self):
        """"""
        # pylint: disable=protected-access
        self._upload_url = "/".join(
            [self.jss._url, self._url, self.resource_type, self.id_type,
             str(self._id)])
607346
async function upload(localFiles, options, onProgess){

    // the index of the current uploaded file
    let fileUploadIndex = 0;

    async function uploadFile(localFile, remoteFilename){

        // increment upload index
        fileUploadIndex++;

        // get file stats
        try{
            const stats = await _fs.statx(localFile);

            // check if file is directory
            if (stats.isDirectory()) {
                _mculogger.error('Path "' + localFile + '" is a directory.');
                return;
            }

        // local file available
        }catch (err){
            _logger.error('Local file not found "' + localFile + '" skipping...');
            _logger.debug(err);
            return;
        }

        // display filename
        _logger.log('Uploading "' + localFile + '" >> "' + remoteFilename + '"...');

        // normalize the remote filename (strip relative parts)
        remoteFilename = remoteFilename.replace(/\.\.\//g, '').replace(/\.\./g, '').replace(/^\.\//, '');

        // delete old file (may existent)
        await _nodeMcuConnector.remove(remoteFilename);

        // start file transfer
        await _nodeMcuConnector.upload(localFile, remoteFilename, options, function(current, total){
            // proxy and append file-number
            onProgess(current, total, fileUploadIndex);
        });

        // compile flag set ? and is a lua file ?
        if (options.compile && _path.extname(localFile).toLowerCase() == '.lua'){
            _mculogger.log(' |- compiling lua file..');

            await _nodeMcuConnector.compile(remoteFilename);
            _mculogger.log(' |- success');

            // drop original lua file
            await _nodeMcuConnector.remove(remoteFilename);
            _mculogger.log(' |- original Lua file removed');
        }
    }

    // try to establish a connection to the module
    await getConnection();

    // single file upload ?
    if (localFiles.length == 1){
        // extract first element
        const localFile = localFiles[0];

        // filename defaults to original filename minus path.
        // this behaviour can be overridden by --keeppath and --remotename options
        const remoteFile = options.remotename ? options.remotename : (options.keeppath ? localFile : _path.basename(localFile));

        // start single file upload
        await uploadFile(localFile, remoteFile);

        // log message
        _logger.log('File Transfer complete!');

        // run file ?
        if (options.run === true){
            await run(remoteFile);
        }

    // bulk upload ?
    }else{

        // file available ?
        while (localFiles.length > 0){
             // extract file
             const localFile = localFiles.shift();

             // keep-path option set ?
             const remoteFile = (options.keeppath ? localFile : _path.basename(localFile));

             // trigger upload
             await uploadFile(localFile, remoteFile);
        }

        // log message
        _logger.log('Bulk File Transfer complete!');
    }
}
385067
def upload_file_to_bucket(self, bucket, file_path, key, is_public=False):
        

        with open(file_path, 'rb') as data:
            self.__s3.upload_fileobj(data, bucket, key)

        if is_public:
            self.__s3.put_object_acl(ACL='public-read', Bucket=bucket, Key=key)

        bucket_location = self.__s3.get_bucket_location(Bucket=bucket)
        file_url = "https://s3-{0}.amazonaws.com/{1}/{2}".format(
            bucket_location['LocationConstraint'],
            bucket,
            key)

        return file_url
757787
def upload(file)
      # get the path for upload
      response = Atlas.client.get("#{url_builder.box_provider_url}/upload")

      # upload the file
      upload_url = response['upload_path']
      Excon.put(upload_url, body: file)
    end
940699
def _upload_file(compute, project_id, file_path, path):
    
    path = "/projects/{}/files/{}".format(project_id, path.replace("\\", "/"))
    with open(file_path, "rb") as f:
        yield from compute.http_query("POST", path, f, timeout=None)
102380
def upload():
    """"""
    try:
        o = check_output(['twine', 'upload'] + glob('dist/*'))
    except CalledProcessError:
        call(['twine', 'upload'] + glob('dist/*'))
        raise
    print(o.decode('utf-8'))
1366334
def uploadFile(uploadfunc, fileindex, existing, uf, skip_broken=False):
    

    if uf["location"].startswith("toilfs:") or uf["location"].startswith("_:"):
        return
    if uf["location"] in fileindex:
        uf["location"] = fileindex[uf["location"]]
        return
    if not uf["location"] and uf["path"]:
        uf["location"] = schema_salad.ref_resolver.file_uri(uf["path"])
    if uf["location"].startswith("file://") and not os.path.isfile(uf["location"][7:]):
        if skip_broken:
            return
        else:
            raise cwltool.errors.WorkflowException(
                "File is missing: %s" % uf["location"])
    uf["location"] = write_file(
        uploadfunc, fileindex, existing, uf["location"])
875084
def upload(self):
        ''''''
        info = pcs.upload(self.cookie, self.row[SOURCEPATH_COL],
                          self.row[PATH_COL], self.upload_mode)
        if info:
            self.emit('uploaded', self.row[FID_COL])
        else:
            self.emit('network-error', self.row[FID_COL])
1176378
def upload(self, thread_uuid, file_path, description=None):
        
        url = "threads/%s/entries" % thread_uuid
        return self.core.upload(file_path, url, description)
405014
def _local_upload(self, filepath, remove=False):
        """"""
        if os.path.isfile(filepath):
            filename = os.path.basename(os.path.abspath(filepath))
            if filename and self.__isValidFilename(filename):
                suffix = self.__getFilenameSuffix(filename)
                try:
                    self.__unpack_tgz(os.path.abspath(filepath)) if self.__isValidTGZ(suffix) else self.__unpack_zip(os.path.abspath(filepath))
                finally:
                    if remove is True:
                        os.remove(filepath)
            else:
                raise InstallError("Invalid Filename")
        else:
            raise InstallError("Invalid Filepath")
584502
public void submitTopology() throws TopologySubmissionException {
    // build primary runtime config first
    Config primaryRuntime = Config.newBuilder()
          .putAll(LauncherUtils.getInstance().createPrimaryRuntime(topology)).build();
    // call launcher directly here if in dry-run mode
    if (Context.dryRun(config)) {
      callLauncherRunner(primaryRuntime);
      return;
    }
    // 1. Do prepare work
    // create an instance of state manager
    String statemgrClass = Context.stateManagerClass(config);
    IStateManager statemgr;

    // Create an instance of the launcher class
    String launcherClass = Context.launcherClass(config);
    ILauncher launcher;

    // create an instance of the uploader class
    String uploaderClass = Context.uploaderClass(config);
    IUploader uploader;

    // create an instance of state manager
    try {
      statemgr = ReflectionUtils.newInstance(statemgrClass);
    } catch (IllegalAccessException | InstantiationException | ClassNotFoundException e) {
      throw new TopologySubmissionException(
          String.format("Failed to instantiate state manager class '%s'", statemgrClass), e);
    }

    // create an instance of launcher
    try {
      launcher = ReflectionUtils.newInstance(launcherClass);
    } catch (IllegalAccessException | InstantiationException | ClassNotFoundException e) {
      throw new LauncherException(
          String.format("Failed to instantiate launcher class '%s'", launcherClass), e);
    }

    // create an instance of uploader
    try {
      uploader = ReflectionUtils.newInstance(uploaderClass);
    } catch (IllegalAccessException | InstantiationException | ClassNotFoundException e) {
      throw new UploaderException(
          String.format("Failed to instantiate uploader class '%s'", uploaderClass), e);
    }

    // Put it in a try block so that we can always clean resources
    try {
      // initialize the state manager
      statemgr.initialize(config);

      // initialize the uploader
      uploader.initialize(config);

      // TODO(mfu): timeout should read from config
      SchedulerStateManagerAdaptor adaptor = new SchedulerStateManagerAdaptor(statemgr, 5000);

      // Check if topology is already running
      validateSubmit(adaptor, topology.getName());

      LOG.log(Level.FINE, "Topology {0} to be submitted", topology.getName());

      Config runtimeWithoutPackageURI = Config.newBuilder()
          .putAll(primaryRuntime)
          .putAll(LauncherUtils.getInstance().createAdaptorRuntime(adaptor))
          .put(Key.LAUNCHER_CLASS_INSTANCE, launcher)
          .build();

      PackingPlan packingPlan = LauncherUtils.getInstance()
          .createPackingPlan(config, runtimeWithoutPackageURI);

      // The packing plan might call for a number of containers different than the config
      // settings. If that's the case we need to modify the configs to match.
      runtimeWithoutPackageURI =
          updateNumContainersIfNeeded(runtimeWithoutPackageURI, topology, packingPlan);

      // If the packing plan is valid we will upload necessary packages
      URI packageURI = uploadPackage(uploader);

      // Update the runtime config with the packageURI
      Config runtimeAll = Config.newBuilder()
          .putAll(runtimeWithoutPackageURI)
          .put(Key.TOPOLOGY_PACKAGE_URI, packageURI)
          .build();

      callLauncherRunner(runtimeAll);

    } catch (LauncherException | PackingException e) {
      // we undo uploading of topology package only if launcher fails to
      // launch topology, which will throw LauncherException or PackingException
      uploader.undo();
      throw e;
    } finally {
      SysUtils.closeIgnoringExceptions(uploader);
      SysUtils.closeIgnoringExceptions(launcher);
      SysUtils.closeIgnoringExceptions(statemgr);
    }
  }
361929
def upload(self):
    """"""
    if not self._converter:
      raise RuntimeError(
          'Must set _converter on subclass or via set_converter before calling '
          'upload.')

    if not self.credentials:
      raise RuntimeError('Must provide credentials to use upload callback.')

    def upload_callback(test_record_obj):
      proto = self._convert(test_record_obj)
      self.upload_result = send_mfg_inspector_data(
          proto, self.credentials, self.destination_url)

    return upload_callback
380598
function ftpProcessLocation(inPath, cb) {
    if (!toTransfer[inPath]) {
      cb(new Error('Data for ' + inPath + ' not found'));
    }
    ftpCwd('/' + remoteRoot + '/' + inPath.replace(/\\/gi, '/'), function(err) {
      var files;

      if (err) {
        grunt.warn('Could not switch to remote folder!');
      }

      currPath = inPath;
      files = toTransfer[inPath];
      async.forEach(files, ftpPut, function(err) {
        if (err) {
          grunt.warn('Failed uploading files!');
        }
        cb(null);
      });
    });
  }
1346887
function getFileUrl (repo, path, sha, line) {
  return HOST + "/" + repo + "/src/" + sha + "/" + path + "#cl-" + line;
}
1049952
def _upload(self, archive, region):
        
        # Generate source upload url
        url = self.client.execute_command(
            'generateUploadUrl',
            {'parent': 'projects/{}/locations/{}'.format(
                self.session.get_default_project(),
                region)}).get('uploadUrl')
        log.debug("uploading function code %s", url)
        http = self._get_http_client(self.client)
        headers, response = http.request(
            url, method='PUT',
            headers={
                'content-type': 'application/zip',
                'Content-Length': '%d' % archive.size,
                'x-goog-content-length-range': '0,104857600'
            },
            body=open(archive.path, 'rb')
        )
        log.info("function code uploaded")
        if headers['status'] != '200':
            raise RuntimeError("%s\n%s" % (headers, response))
        return url