Process an upload, recursive
549410
function() {

        var fileIndex;

        if (stop_loop) {
          return false;
        }

        // Check to see if are in queue mode
        if (opts.queuefiles > 0 && processingQueue.length >= opts.queuefiles) {
          return pause(opts.queuewait);
        } else {
          // Take first thing off work queue
          fileIndex = workQueue[0];
          workQueue.splice(0, 1);

          // Add to processing queue
          processingQueue.push(fileIndex);
        }

        try {
          if (beforeEach(files[fileIndex]) !== false) {
            if (fileIndex === files_count) {
              return;
            }
            var reader = new FileReader(),
                max_file_size = 1048576 * opts.maxfilesize;

            reader.index = fileIndex;
            if (files[fileIndex].size > max_file_size) {
              opts.error(errors[2], files[fileIndex], fileIndex);
              // Remove from queue
              processingQueue.forEach(function(value, key) {
                if (value === fileIndex) {
                  processingQueue.splice(key, 1);
                }
              });
              filesRejected++;
              return true;
            }

            reader.onloadend = !opts.beforeSend ? send : function (e) {
              opts.beforeSend(files[fileIndex], fileIndex, function () { send(e); });
            };

            reader.readAsBinaryString(files[fileIndex]);

          } else {
            filesRejected++;
          }
        } catch (err) {
          // Remove from queue
          processingQueue.forEach(function(value, key) {
            if (value === fileIndex) {
              processingQueue.splice(key, 1);
            }
          });
          opts.error(errors[0]);
          return false;
        }

        // If we still have work to do,
        if (workQueue.length > 0) {
          process();
        }
      }
605475
function processFileResponse(req, res, next) {
  var fileDetails = req.appformsResultPayload.data;
  if (fileDetails.stream) {
    var headers = {};
    headers["Content-Type"] = fileDetails.type;//Setting the file content type. Mime types are set by the file handler.
    headers["Content-Disposition"] = "attachment; filename=" + fileDetails.name;
    res.writeHead(200, headers);
    fileDetails.stream.pipe(res);
    fileDetails.stream.resume(); //Unpausing the stream as it was paused by the file handler
  } else {
    return next('Error getting submitted file - result: ' + JSON.stringify(fileDetails));
  }
}
254773
function processMultipartNode(node, options) {
    options = options || {};

    var data = (node.childNodes && node.childNodes.map(function(tree) {
        return createBodystructure(tree, options);
    }) || [[]]).
        concat([
            // body subtype
            options.upperCaseKeys ? node.multipart && node.multipart.toUpperCase() || null : node.multipart,
            // body parameter parenthesized list
            node.parsedHeader['content-type'] &&
                node.parsedHeader['content-type'].hasParams &&
                flatten(Object.keys(node.parsedHeader['content-type'].params).map(function(key) {
                    return [
                        options.upperCaseKeys ? key.toUpperCase() : key,
                        node.parsedHeader['content-type'].params[key]];
                })) || null]);

    if (options.body) {
        return data;
    } else {
        return data.
            // skip body MD5 from extension fields
            concat(getExtensionFields(node, options).slice(1));
    }
}
187110
public function process ()
		{
			if (!empty( $this->_params ))
			{
				if ($this->getIsUploading())
					$this->uploadChunk();
				else
					$this->testChunk();
			}
		}
197316
def upload_file_handle(
            self,
            bucket: str,
            key: str,
            src_file_handle: typing.BinaryIO,
            content_type: str=None,
            metadata: dict=None):
        
        raise NotImplementedError()
1267572
function ($placeholder, file, that) {
				$.ajax({
					type: "post",
					url: that.options.imagesUploadScript,
					xhr: function () {
						var xhr = new XMLHttpRequest();
						xhr.upload.onprogress = that.updateProgressBar;
						return xhr;
					},
					cache: false,
					contentType: false,
					complete: function (jqxhr) {
						that.uploadCompleted(jqxhr, $placeholder);
					},
					processData: false,
					data: that.options.formatData(file)
				});
			}
954842
def pass_multipart(with_completed=False):
    """"""
    def decorate(f):
        @wraps(f)
        def inner(self, bucket, key, upload_id, *args, **kwargs):
            obj = MultipartObject.get(
                bucket, key, upload_id, with_completed=with_completed)
            if obj is None:
                abort(404, 'uploadId does not exists.')
            return f(self, obj, *args, **kwargs)
        return inner
    return decorate
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)
1016279
function(err, str, fileDetails) {
      if (err) {
        return cb(err);
      }

      var res = {
        stream: str,
        type: fileDetails.contentType,
        length: fileDetails.length,
        name: fileDetails.filename
      };
      return cb(undefined, res);
    }
258742
function processArray(req, res, nextarray) {
    if (!nextarray || !nextarray.length)
        return;
    var proc = nextarray.shift();
    proc(req, res, function () {
        processArray(req, res, nextarray);
    });
}
1175971
function processGithubFile (options, callback) {
  var item = options.item
  var key = options.key
  var json = options.json

  function respond (content) {
    if (isFeatureCollection(content)) {
      content.name = key
      content.updated_at = json.updated_at
      return content
    }
    return false
  }

  if (item.truncated) {
    return request({
      url: item.raw_url
    }, function (err, content) {
      if (err) return callback(err)

      callback(null, respond(content))
    })
  }

  try {
    var content = JSON.parse(item.content)
  } catch (e) {
    var msg = 'could not parse file contents of ' + key + ': ' + e.message
    return callback(new Error(msg))
  }

  callback(null, respond(content))
}
155666
protected function process()
    {

        // query whether or not we've the flag to upload the image files has been set
        if ($this->getSubject()->getConfiguration()->hasParam(ConfigurationKeys::COPY_IMAGES)) {
            // query whether or not we've to upload the image files
            if ($this->getSubject()->getConfiguration()->getParam(ConfigurationKeys::COPY_IMAGES)) {
                // initialize the array for the actual images
                $actualImageNames = array();

                // iterate over the available image fields
                foreach (array_keys($this->getImageTypes()) as $imageColumnName) {
                    // do nothing if the column is empty
                    if (!$this->hasValue($imageColumnName)) {
                        continue;
                    }

                    // override the image path with the new one, if the image has already been processed
                    if (isset($actualImageNames[$imageName = $this->getValue($imageColumnName)])) {
                        $this->setValue($imageColumnName, $actualImageNames[$imageName]);
                        continue;
                    }

                    // upload the file and set the new image path
                    $imagePath = $this->getSubject()->uploadFile($imageName);

                    // log a message that the image has been copied
                    $this->getSubject()
                         ->getSystemLogger()
                         ->debug(
                             sprintf(
                                 'Successfully copied image type %s with name %s => %s',
                                 $imageColumnName,
                                 $imageName,
                                 $imagePath
                             )
                         );

                    // override the image path with the new one
                    $this->setValue($imageColumnName, $imagePath);

                        // add the image to the list with processed images
                    $actualImageNames[$imageName] = $imagePath;
                }

                // query whether or not, we've additional images
                if ($additionalImages = $this->getValue(ColumnKeys::ADDITIONAL_IMAGES, null, array($this, 'explode'))) {
                    // process all the additional images
                    foreach ($additionalImages as $key => $additionalImageName) {
                        // query whether or not the image has already been processed
                        if (isset($actualImageNames[$additionalImageName])) {
                            // if yes, override the image path
                            $additionalImages[$key] = $imagePath;
                            // and override the image path with the new one
                            $this->setValue($imageColumnName, $actualImageNames[$additionalImageName]);
                            continue;
                        }

                        // upload the file and set the new image path
                        $imagePath = $this->getSubject()->uploadFile($additionalImageName);

                        // log a message that the image has been copied
                        $this->getSubject()
                             ->getSystemLogger()
                             ->debug(
                                 sprintf(
                                     'Successfully copied additional image wth name %s => %s',
                                     $additionalImageName,
                                     $imagePath
                                 )
                             );

                        // override the image path
                        $additionalImages[$key] = $imagePath;

                        // add the image to the list with processed images
                        $actualImageNames[$additionalImageName] = $imagePath;
                    }

                    // override the image paths with the new one
                    $this->setValue(ColumnKeys::ADDITIONAL_IMAGES, implode(',', $additionalImages));
                }
            }
        }
    }
757137
function processStackItem(out, stack, rootPath, userFilter, readMode) {
  // Initialize a new file object.
  const initFile = (dirPath) => {
    return (fileName, callback) => {
      const filePath = path.join(dirPath, fileName);
      fs.stat(filePath, (error, stats) => {
        async.nextTick(callback, error, {
          path: path.relative(rootPath, filePath),
          stats,
        });
      });
    };
  };

  // Filter supported files.
  const filterSupported = () => {
    return (file, callback) => {
      const keep = file.stats.isFile() || file.stats.isDirectory();
      async.nextTick(callback, null, keep);
    };
  };

  // Filter output files.
  const filterOutput = () => {
    return (file, callback) => {
      const keep = file.stats.isFile() && userFilter(file);
      async.nextTick(callback, null, keep);
    };
  };

  // Read a file's data.
  const readData = () => {
    return (file, callback) => {
      const filePath = path.join(rootPath, file.path);
      read(filePath, readMode, (error, data) => {
        async.nextTick(callback, error, Object.assign({}, file, { data }));
      });
    };
  };

  return (callback) => {
    const dirPath = stack.shift();
    async.waterfall([
      cb => fs.readdir(dirPath, cb),
      (fileNames, cb) => async.map(fileNames, initFile(dirPath), cb),
      (files, cb) => async.filter(files, filterSupported(), cb),
      (files, cb) => populateStack(stack, rootPath, files, cb),
      (files, cb) => async.filter(files, filterOutput(), cb),
      (files, cb) => async.map(files, readData(), cb),
    ], (error, result) => {
      if (error) {
        async.nextTick(callback, error);
        return;
      }

      out.push(...result);
      async.nextTick(callback, null);
    });
  };
}
1004574
def _process_file(self, obj, fobj, field):
        
        from uliweb import settings
        
        paths = []
        upload_to = self.upload_to or self._get_upload_path(field, 'upload_to', obj)
        if upload_to:
            self.fileserving.to_path = upload_to
        upload_to_sub = self.upload_to_sub or self._get_upload_path(field, 'upload_to_sub', obj)
        if upload_to_sub:
            paths.append(upload_to_sub)
        paths.append(fobj['filename'])
        
        return self.fileserving.save_file(os.path.join(*paths), 
            fobj['file'], replace=self.file_replace, 
            convert=self.file_convert)
289807
def run(self):
        
        self._running.set()
        self._status = TransferState.RUNNING
        self._time_started = time.time()

        # Initializes the upload
        self._initialize_upload()

        # Opens the file for reading in binary mode.
        try:
            with io.open(self._file_path, mode='rb') as fp:
                # Creates a partitioned file
                parted_file = UPartedFile(
                    fp, self._file_size, self._part_size, self._upload_id,
                    self._retry, self._timeout, self.session, self._api
                )

                # Iterates over parts and submits them for upload.
                for _ in parted_file:
                    if self._stop_signal:
                        return
                    self._running.wait()
                    self._bytes_done += self._part_size
                    # If the progress callback is set we need to provide a
                    # progress object for it.
                    if self._progress_callback:
                        progress = Progress(
                            parted_file.total, parted_file.total_submitted,
                            self._bytes_done, self._file_size, self.duration
                        )
                        self._progress_callback(progress)
        except IOError:
            raise SbgError('Unable to open file {}'.format(self._file_path))
        except Exception as e:
            # If the errorback callback is set call it with status
            self._status = TransferState.FAILED
            if self._errorback:
                self._errorback(self._status)
            else:
                raise SbgError(six.text_type(e))

        # Finalizes the upload.
        self._finalize_upload()
        self._status = TransferState.COMPLETED
        # If the callback is set call it.
        if self._callback:
            self._callback(self._status)
1312761
function uploadRouter(downloads, req, res, next) {
    if (req.originalUrl.match(/amorphic\/xhr\?path\=/) && url.parse(req.originalUrl, true).query.file && req.method === 'POST') {
        processFile(req, res, next, downloads);
    }
    else {
        next();
    }
}
539299
def _flush(self):
        
        # Initialize multipart upload
        if self._upload_id is None:
            with _handle_oss_error():
                self._upload_id = self._bucket.init_multipart_upload(
                    self._key).upload_id

        # Upload part with workers
        response = self._workers.submit(
            self._bucket.upload_part, key=self._key, upload_id=self._upload_id,
            part_number=self._seek, data=self._get_buffer().tobytes())

        # Save part information
        self._write_futures.append(
            dict(response=response, part_number=self._seek))