Uploads a new file to this folder.

@param callback the callback which allows file content to be written on output stream.
@param name     the name to give the uploaded file.
@return the uploaded file's info.
556266
public BoxFile.Info uploadFile(UploadFileCallback callback, String name) {
        FileUploadParams uploadInfo = new FileUploadParams()
                .setUploadFileCallback(callback)
                .setName(name);
        return this.uploadFile(uploadInfo);
    }
143990
function(params, callback) {
                var url = params.url,
                    fileSize,
                    originalFileName,
                    threadId,
                    fileUniqueId,
                    fileObject,
                    data = params.data,
                    method = (typeof params.method == 'string')
                        ? params.method
                        : 'GET',
                    fileUploadUniqueId = (typeof params.uniqueId == 'string')
                        ? params.uniqueId
                        : 'uniqueId',
                    hasError = false;

                if (!url) {
                    callback({
                        hasError: true,
                        errorCode: 6201,
                        errorMessage: CHAT_ERRORS[6201]
                    });
                    return;
                }

                var hasFile = false;

                httpRequestObject[eval('fileUploadUniqueId')] = new XMLHttpRequest(),
                    settings = params.settings;

                httpRequestObject[eval('fileUploadUniqueId')].timeout = (settings && typeof parseInt(settings.timeout) > 0 && settings.timeout > 0)
                    ? settings.timeout
                    : httpRequestTimeout;

                httpRequestObject[eval('fileUploadUniqueId')]
                    .addEventListener('error', function(event) {
                        if (callback) {
                            if (hasFile) {
                                hasError = true;
                                fireEvent('fileUploadEvents', {
                                    threadId: threadId,
                                    uniqueId: fileUniqueId,
                                    state: 'UPLOAD_ERROR',
                                    progress: 0,
                                    fileInfo: {
                                        fileName: originalFileName,
                                        fileSize: fileSize
                                    },
                                    fileObject: fileObject,
                                    errorCode: 6200,
                                    errorMessage: CHAT_ERRORS[6200] + ' (XMLHttpRequest Error Event Listener)'
                                });
                            }
                            callback({
                                hasError: true,
                                errorCode: 6200,
                                errorMessage: CHAT_ERRORS[6200] + ' (XMLHttpRequest Error Event Listener)'
                            });
                        }
                    }, false);

                httpRequestObject[eval('fileUploadUniqueId')].addEventListener('abort',
                    function(event) {
                        if (callback) {
                            if (hasFile) {
                                hasError = true;
                                fireEvent('fileUploadEvents', {
                                    threadId: threadId,
                                    uniqueId: fileUniqueId,
                                    state: 'UPLOAD_CANCELED',
                                    progress: 0,
                                    fileInfo: {
                                        fileName: originalFileName,
                                        fileSize: fileSize
                                    },
                                    fileObject: fileObject,
                                    errorCode: 6303,
                                    errorMessage: CHAT_ERRORS[6303]
                                });
                            }
                            callback({
                                hasError: true,
                                errorCode: 6303,
                                errorMessage: CHAT_ERRORS[6303]
                            });
                        }
                    }, false);

                try {
                    if (method == 'GET') {
                        if (typeof data === 'object' && data !== null) {
                            var keys = Object.keys(data);

                            if (keys.length > 0) {
                                url += '?';

                                for (var i = 0; i < keys.length; i++) {
                                    var key = keys[i];
                                    url += key + '=' + data[key];
                                    if (i < keys.length - 1) {
                                        url += '&';
                                    }
                                }
                            }
                        }
                        else if (typeof data === 'string' && data !== null) {
                            url += '?' + data;
                        }

                        httpRequestObject[eval('fileUploadUniqueId')].open(method, url, true);

                        if (typeof params.headers === 'object') {
                            for (var key in params.headers) {
                                httpRequestObject[eval('fileUploadUniqueId')].setRequestHeader(key, params.headers[key]);
                            }
                        }

                        httpRequestObject[eval('fileUploadUniqueId')].send();
                    }

                    if (method === 'POST' && data) {

                        httpRequestObject[eval('fileUploadUniqueId')].open(method, url, true);

                        if (typeof params.headers === 'object') {
                            for (var key in params.headers) {
                                httpRequestObject[eval('fileUploadUniqueId')].setRequestHeader(key, params.headers[key]);
                            }
                        }

                        if (typeof data == 'object') {
                            if (data.hasOwnProperty('image') || data.hasOwnProperty('file')) {
                                hasFile = true;
                                var formData = new FormData();
                                for (var key in data) {
                                    formData.append(key, data[key]);
                                }

                                fileSize = data.fileSize;
                                originalFileName = data.originalFileName;
                                threadId = data.threadId;
                                fileUniqueId = data.uniqueId;
                                fileObject = (data['image'])
                                    ? data['image']
                                    : data['file'];

                                httpRequestObject[eval('fileUploadUniqueId')].upload.onprogress = function(event) {
                                    if (event.lengthComputable && !hasError) {
                                        fireEvent('fileUploadEvents', {
                                            threadId: threadId,
                                            uniqueId: fileUniqueId,
                                            state: 'UPLOADING',
                                            progress: Math.round((event.loaded / event.total) * 100),
                                            fileInfo: {
                                                fileName: originalFileName,
                                                fileSize: fileSize
                                            },
                                            fileObject: fileObject
                                        });
                                    }
                                };

                                httpRequestObject[eval('fileUploadUniqueId')].send(formData);
                            }
                            else {
                                httpRequestObject[eval('fileUploadUniqueId')].setRequestHeader(
                                    'Content-Type',
                                    'application/x-www-form-urlencoded');

                                var keys = Object.keys(data);

                                if (keys.length > 0) {
                                    sendData = '';

                                    for (var i = 0; i < keys.length; i++) {
                                        var key = keys[i];
                                        sendData += key + '=' + data[key];
                                        if (i < keys.length - 1) {
                                            sendData += '&';
                                        }
                                    }
                                }

                                httpRequestObject[eval('fileUploadUniqueId')].send(sendData);
                            }
                        }
                        else {
                            httpRequestObject[eval('fileUploadUniqueId')].send(data);
                        }
                    }
                }
                catch (e) {
                    callback && callback({
                        hasError: true,
                        cache: false,
                        errorCode: 6200,
                        errorMessage: CHAT_ERRORS[6200] + ' (Request Catch Error)' + e
                    });
                }

                httpRequestObject[eval('fileUploadUniqueId')].onreadystatechange = function() {
                    if (httpRequestObject[eval('fileUploadUniqueId')].readyState == 4) {
                        if (httpRequestObject[eval('fileUploadUniqueId')].status == 200) {
                            if (hasFile) {
                                hasError = false;
                                fireEvent('fileUploadEvents', {
                                    threadId: threadId,
                                    uniqueId: fileUniqueId,
                                    state: 'UPLOADED',
                                    progress: 100,
                                    fileInfo: {
                                        fileName: originalFileName,
                                        fileSize: fileSize
                                    },
                                    fileObject: fileObject
                                });
                            }

                            callback && callback({
                                hasError: false,
                                cache: false,
                                result: {
                                    responseText: httpRequestObject[eval('fileUploadUniqueId')].responseText,
                                    responseHeaders: httpRequestObject[eval('fileUploadUniqueId')].getAllResponseHeaders()
                                }
                            });
                        }
                        else {
                            if (hasFile) {
                                hasError = true;
                                fireEvent('fileUploadEvents', {
                                    threadId: threadId,
                                    uniqueId: fileUniqueId,
                                    state: 'UPLOAD_ERROR',
                                    progress: 0,
                                    fileInfo: {
                                        fileName: originalFileName,
                                        fileSize: fileSize
                                    },
                                    fileObject: fileObject,
                                    errorCode: 6200,
                                    errorMessage: CHAT_ERRORS[6200] + ' (Request Status != 200)',
                                    statusCode: httpRequestObject[eval('fileUploadUniqueId')].status
                                });
                            }
                            callback && callback({
                                hasError: true,
                                errorMessage: httpRequestObject[eval('fileUploadUniqueId')].responseText,
                                errorCode: httpRequestObject[eval('fileUploadUniqueId')].status
                            });
                        }
                    }
                };
            }
1085764
public void uploadContent(@NonNull final String folder, @NonNull final ContentData data, @Nullable Callback<ComapiResult<UploadContentResponse>> callback) {
        adapter.adapt(uploadContent(folder, data), callback);
    }
1197339
function(callback) {
            fs.exists(file, function(exists) {
                if(!exists) {
                    rawData = file;
                    if(typeof rawData === "string") rawData = new Buffer(file);
                    return callback();
                }

                fs.readFile(file, function(err, data) {
                    if(err) return callback(err);
                    rawData = data;
                    return callback();
                });
            });
        }
164868
function _loadFile(filename, callback) {
    callback = callback || function () { };

    if (filename.charAt(0) == '.') {
      callback();
      return;
    }

    var filepath = path.join(folder, filename);
    fs.readFile(filepath, function (err, data) {
      if (err) {
        console.error('Failed to read file ' + filepath + ' err:', err);
        callback(err);
        return;
      }
      try {
        _loadData(filename, data.toString());
      }
      catch (e) {
        console.info('Object ' + filename + ' was not yet fully written, exception:', e);
        // There will be another notification of change when the last write to file is completed.
        // Meanwhile leave the previous value.
        if (loader) {
          // Store this error to wait until file will be successfully loaded for the 1st time.
          loader.errors[filename] = e;
        }
        // Don't return error to continue asynchronous loading of other files. Errors are assembled on loader.
        callback();
        return;
      }
      console.log('Loaded ' + filename);
      if (loader) {
        if (loader.errors[filename]) {
          // File that previously failed to load, now is loaded.
          delete loader.errors[filename];
          var countErrors = Object.keys(loader.errors).length;
          if (countErrors === 0) {
            // All errors are fixed. This is the time to complete loading.
            var initcb = loader.callback;
            loader = null;
            _updateSingleton();
            initcb();
          }
        }
      }
      callback();
    });
  }
882275
public HttpRequest form(String name, File file) {
		return form(name, file, file.getName());
	}
1215634
public BoxFile.Info uploadFile(InputStream fileContent, String name) {
        FileUploadParams uploadInfo = new FileUploadParams()
                .setContent(fileContent)
                .setName(name);
        return this.uploadFile(uploadInfo);
    }
136280
function(params, callback) {
                var uploadUniqueId,
                    uploadThreadId;

                var uploadFileData = {},
                    fileExtension;

                if (params) {
                    if (typeof params.fileUrl !== 'undefined') {
                        uploadFileData.url = params.fileUrl;
                    }

                    if (typeof params.fileExtension !== 'undefined') {
                        fileExtension = params.fileExtension;
                    }
                    else {
                        fileExtension = 'png';
                    }

                    if (typeof params.fileName == 'string') {
                        uploadFileData.filename = params.fileName;
                    }
                    else {
                        uploadFileData.filename = Utility.generateUUID() + '.' + fileExtension;
                    }

                    if (typeof params.uniqueId == 'string') {
                        uploadUniqueId = params.uniqueId;
                    }
                    else {
                        uploadUniqueId = Utility.generateUUID();
                    }

                    if (parseInt(params.threadId) > 0) {
                        uploadThreadId = params.threadId;
                    }
                    else {
                        uploadThreadId = 0;
                    }

                    uploadFileData.isPublic = true;
                }

                httpRequest({
                    url: SERVICE_ADDRESSES.POD_DRIVE_ADDRESS + SERVICES_PATH.DRIVE_UPLOAD_FILE_FROM_URL,
                    method: 'POST',
                    headers: {
                        '_token_': token,
                        '_token_issuer_': 1
                    },
                    data: uploadFileData,
                    uniqueId: uploadUniqueId
                }, function(result) {
                    if (!result.hasError) {
                        try {
                            var response = (typeof result.result.responseText == 'string')
                                ? JSON.parse(result.result.responseText)
                                : result.result.responseText;
                            callback({
                                hasError: response.hasError,
                                result: response.result
                            });
                        }
                        catch (e) {
                            callback({
                                hasError: true,
                                errorCode: 999,
                                errorMessage: 'Problem in Parsing result',
                                error: e
                            });
                        }
                    }
                    else {
                        callback({
                            hasError: true,
                            errorCode: result.errorCode,
                            errorMessage: result.errorMessage
                        });
                    }
                });

                return {
                    uniqueId: uploadUniqueId,
                    threadId: uploadThreadId,
                    participant: userInfo,
                    content: {
                        file: {
                            uniqueId: uploadUniqueId,
                            fileUrl: params.fileUrl
                        }
                    }
                };
            }
126842
protected void uploadFile() {

        hideOkAndUploadButtons();
        CmsUploader uploader = new CmsUploader();
        CmsFileInfo info = m_fileInput.getFiles()[0];
        info.setOverrideFileName(
            CmsStringUtil.joinPaths(m_handler.getTargetFolderPath(), m_handler.getFileName(info.getFileName())));
        uploader.uploadFiles(
            CmsCoreProvider.get().link(I_CmsUploadConstants.UPLOAD_ACTION_JSP_URI),
            CmsResource.getFolderPath(m_handler.getTargetFolderPath()),
            true,
            Collections.singletonList(info),
            Collections.<String> emptyList(),
            this);
        showProgress();
    }
1251650
public function getUploadedFile($name)
    {
        $filePath = '';
        if (array_key_exists($name, $_FILES)) {
            $filePath = $_FILES[$name]['tmp_name'];
        } elseif (array_key_exists($name, $this->parameters)) {
            $filePath = substr($this->parameters[$name], 1);
        }

        return $filePath;
    }
131152
public function getUploadedFile($name) {
        if(!isset($_FILES[$name])) return false;

        if(is_array($_FILES[$name]['name'])) {
            $result = array();
            foreach($_FILES[$name]['name'] as $key => $name) {
                $file = new UploadedFile($name, $_FILES[$name]['tmp_name'][$key], $_FILES[$name]['size'][$key], $_FILES[$name]['type'][$key], $_FILES[$name]['error'][$key] );
                $result[] = $file;
            }
            return $result;
        }else {
            $file = new UploadedFile($_FILES[$name]['name'], $_FILES[$name]['tmp_name'], $_FILES[$name]['size'], $_FILES[$name]['type'], $_FILES[$name]['error']);
            return $file;
        }
    }
126003
public function of($name, Closure $callback = null)
    {
        if (!isset($this->names[$name])) {
            $this->names[$name]       = $this->make($callback);
            $this->names[$name]->name = $name;
        }
        $form = $this->names[$name];
        event('form.' . $name, [&$form]);
        event(new Form($name, $form));
        return $form;
    }
265814
function File(data, callback) {
    stream.Duplex.call(this);

    this._header = new Header();
    this._tracks = [];

    if (data && buffer.Buffer.isBuffer(data)) {
        this.setData(data, callback || noop);
    }
}
1287666
protected void callback(String name, Bundle resultData) {
    if (resultData == null) resultData = new Bundle();
    resultData.putString(Groundy.KEY_CALLBACK_NAME, name);
    resultData.putSerializable(Groundy.TASK_IMPLEMENTATION, getClass());
    send(OnCallback.class, resultData);
  }
15060
public function uploadFile(string $name, string $filename): void
    {
        $sourceFile = FilePath::parse($filename);
        if (!file_exists($sourceFile->__toString())) {
            throw new InvalidUploadedFileException('File "' . $sourceFile . '" does not exist.');
        }

        $destinationFile = tempnam(sys_get_temp_dir(), 'php');
        copy($sourceFile->__toString(), $destinationFile);

        $this->setUploadedFile(
            $name,
            new UploadedFile(
                FilePath::parse($destinationFile),
                $sourceFile->__toString(),
                filesize($destinationFile)
            )
        );
    }
186367
public static UploadFile getFileParam(String name){
		MultipartFormData multipart = getMultipart();
		if(null != multipart){
			return multipart.getFile(name);
		}
		return null;
	}
110143
def upload_file(
        self,
        filename,
        upload_as=None,
        blocksize=None,
        callback=None,
        information_callback=None,
        allow_timeout=False,
    ):
        """"""

        with delayed_close(
            filename if hasattr(filename, "read") else open(filename, "rb")
        ) as file:
            filename = upload_as or os.path.split(filename)[1]
            try:
                file.seek(0, 2)
                if file.tell() > self.config.max_file:
                    raise ValueError(
                        f"File must be at most {self.config.max_file >> 30} GB"
                    )
            finally:
                try:
                    file.seek(0)
                except Exception:
                    pass

            files = Data(
                {"file": {"name": filename, "value": file}},
                blocksize=blocksize,
                callback=callback,
            )

            headers = {"Origin": BASE_URL}
            headers.update(files.headers)

            while True:
                key, server, file_id = self._generate_upload_key(
                    allow_timeout=allow_timeout
                )
                info = dict(
                    key=key,
                    server=server,
                    file_id=file_id,
                    room=self.room_id,
                    filename=filename,
                    len=files.len,
                    resumecount=0,
                )
                if information_callback:
                    if information_callback(info) is False:
                        continue
                break

            params = {"room": self.room_id, "key": key, "filename": filename}

            if self.key:
                params["roomKey"] = self.key
            if self.password:
                params["password"] = self.password

            while True:
                try:
                    post = self.conn.post(
                        f"https://{server}/upload",
                        params=params,
                        data=files,
                        headers=headers,
                    )
                    post.raise_for_status()
                    break

                except requests.exceptions.ConnectionError as ex:
                    if "aborted" not in repr(ex):  # ye, that's nasty but "compatible"
                        raise
                    try:
                        resume = self.conn.get(
                            f"https://{server}/rest/uploadStatus",
                            params={"key": key, "c": 1},
                        ).text
                        resume = from_json(resume)
                        resume = resume["receivedBytes"]
                        if resume <= 0:
                            raise ConnectionError("Cannot resume")
                        file.seek(resume)
                        files = Data(
                            {"file": {"name": filename, "value": file}},
                            blocksize=blocksize,
                            callback=callback,
                            logical_offset=resume,
                        )
                        headers.update(files.headers)
                        params["startAt"] = resume
                        info["resumecount"] += 1
                        if information_callback:
                            information_callback(info)
                    except requests.exceptions.ConnectionError as iex:
                        # ye, that's nasty but "compatible"
                        if "aborted" not in repr(iex):
                            raise
                        continue  # another day, another try
            return file_id