Adds an input file to a request, with the given field name.

@param request The request to be added to.
@param fieldName The name of the field.
@param inputFile The input file.
492755
public static void processInputFileField(MultipartBody request, String fieldName, InputFile inputFile) {
        String fileId = inputFile.getFileID();
        if (fileId != null) {
            request.field(fieldName, fileId, false);
        } else if (inputFile.getInputStream() != null) {
            request.field(fieldName, new InputStreamBody(inputFile.getInputStream(), inputFile.getFileName()), true);
        } else { // assume file is not null (this is existing behaviour as of 1.5.1)
            request.field(fieldName, new FileContainer(inputFile), true);
        }
    }
1032354
private void addPostParams(final Request request) {
        if (friendlyName != null) {
            request.addPostParam("FriendlyName", friendlyName);
        }

        if (uniqueName != null) {
            request.addPostParam("UniqueName", uniqueName);
        }

        if (actions != null) {
            request.addPostParam("Actions", Converter.mapToJson(actions));
        }

        if (actionsUrl != null) {
            request.addPostParam("ActionsUrl", actionsUrl.toString());
        }
    }
117366
public void setInputFile(final URI inputFile) {
        assert inputFile.isAbsolute();
        prop.put(PROPERTY_INPUT_MAP_URI, inputFile.toString());
        // Deprecated since 2.1
        if (inputFile.getScheme().equals("file")) {
            prop.put(PROPERTY_INPUT_MAP, new File(inputFile).getAbsolutePath());
        }
    }
92267
private void addPostParams(final Request request) {
        if (friendlyName != null) {
            request.addPostParam("FriendlyName", friendlyName);
        }

        if (logQueries != null) {
            request.addPostParam("LogQueries", logQueries.toString());
        }

        if (uniqueName != null) {
            request.addPostParam("UniqueName", uniqueName);
        }

        if (callbackUrl != null) {
            request.addPostParam("CallbackUrl", callbackUrl.toString());
        }

        if (callbackEvents != null) {
            request.addPostParam("CallbackEvents", callbackEvents);
        }

        if (fallbackActions != null) {
            request.addPostParam("FallbackActions", Converter.mapToJson(fallbackActions));
        }

        if (initiationActions != null) {
            request.addPostParam("InitiationActions", Converter.mapToJson(initiationActions));
        }

        if (styleSheet != null) {
            request.addPostParam("StyleSheet", Converter.mapToJson(styleSheet));
        }
    }
178234
private void addPostParams(final Request request) {
        if (target != null) {
            request.addPostParam("Target", target.toString());
        }

        if (configurationUrl != null) {
            request.addPostParam("Configuration.Url", configurationUrl);
        }

        if (configurationMethod != null) {
            request.addPostParam("Configuration.Method", configurationMethod.toString());
        }

        if (configurationFilters != null) {
            for (String prop : configurationFilters) {
                request.addPostParam("Configuration.Filters", prop);
            }
        }

        if (configurationTriggers != null) {
            for (String prop : configurationTriggers) {
                request.addPostParam("Configuration.Triggers", prop);
            }
        }

        if (configurationFlowSid != null) {
            request.addPostParam("Configuration.FlowSid", configurationFlowSid);
        }

        if (configurationRetryCount != null) {
            request.addPostParam("Configuration.RetryCount", configurationRetryCount.toString());
        }

        if (configurationReplayAfter != null) {
            request.addPostParam("Configuration.ReplayAfter", configurationReplayAfter.toString());
        }

        if (configurationBufferMessages != null) {
            request.addPostParam("Configuration.BufferMessages", configurationBufferMessages.toString());
        }

        if (configurationBufferWindow != null) {
            request.addPostParam("Configuration.BufferWindow", configurationBufferWindow.toString());
        }
    }
149028
@VisibleForTesting
  public void addSource(InputFile file) {
    if (globalCombinedUnit != null) {
      inputs.add(new ProcessingContext(file, globalCombinedUnit));
    } else {
      inputs.add(ProcessingContext.fromFile(file, options));
    }
  }
1268628
private void addPostParams(final Request request) {
        if (author != null) {
            request.addPostParam("Author", author);
        }

        if (attributes != null) {
            request.addPostParam("Attributes", attributes);
        }

        if (dateCreated != null) {
            request.addPostParam("DateCreated", dateCreated.toString());
        }

        if (dateUpdated != null) {
            request.addPostParam("DateUpdated", dateUpdated.toString());
        }

        if (body != null) {
            request.addPostParam("Body", body);
        }
    }
367433
def addinputfile(project, filename, credentials=None): #pylint: disable=too-many-return-statements
        """"""

        printdebug('Addinputfile: Initialising' )

        user, oauth_access_token = parsecredentials(credentials) #pylint: disable=unused-variable
        response = Project.create(project, user)
        if response is not None:
            return response
        postdata = flask.request.values

        if filename == '': #pylint: disable=too-many-nested-blocks
            #Handle inputsource
            printdebug('Addinputfile: checking for input source' )
            if 'inputsource' in postdata and postdata['inputsource']:
                inputsource = None
                inputtemplate = None
                for profile in settings.PROFILES:
                    for t in profile.input:
                        for s in t.inputsources:
                            if s.id == postdata['inputsource']:
                                inputsource = s
                                inputsource.inputtemplate = t.id
                                inputtemplate = t
                                break
                if not inputsource:
                    for s in settings.INPUTSOURCES:
                        if s.id == postdata['inputsource']:
                            inputsource = s
                if not inputsource:
                    return withheaders(flask.make_response("No such inputsource exists",403),headers={'allow_origin': settings.ALLOW_ORIGIN})
                if not inputtemplate:
                    for profile in settings.PROFILES:
                        for t in profile.input:
                            if inputsource.inputtemplate == t.id:
                                inputtemplate = t
                if inputtemplate is None:
                    return withheaders(flask.make_response("No input template found for inputsource",500),headers={'allow_origin': settings.ALLOW_ORIGIN})
                if inputsource.isfile():
                    if inputtemplate.filename:
                        filename = inputtemplate.filename
                    else:
                        filename = os.path.basename(inputsource.path)
                    xml = addfile(project, filename, user, {'inputsource': postdata['inputsource'], 'inputtemplate': inputtemplate.id}, inputsource)
                    return xml
                elif inputsource.isdir():
                    if inputtemplate.filename:
                        filename = inputtemplate.filename
                    for f in glob.glob(inputsource.path + "/*"):
                        if not inputtemplate.filename:
                            filename = os.path.basename(f)
                        if f[0] != '.':
                            tmpinputsource = clam.common.data.InputSource(id='tmp',label='tmp',path=f, metadata=inputsource.metadata)
                            addfile(project, filename, user, {'inputsource':'tmp', 'inputtemplate': inputtemplate.id}, tmpinputsource)
                            #WARNING: Output is dropped silently here!
                    return "" #200
                else:
                    assert False
            else:
                return withheaders(flask.make_response("No filename or inputsource specified",403),headers={'allow_origin': settings.ALLOW_ORIGIN})
        else:
            #Simply forward to addfile
            return addfile(project,filename,user, postdata)
478267
protected void doHandleUploadRequest(final Request request) {
		// Protect against client-side tampering of disabled/read-only fields.
		if (isDisabled() || isReadOnly()) {
			throw new SystemException("File widget cannot be updated.");
		}

		// Only process on a POST
		if (!"POST".equals(request.getMethod())) {
			throw new SystemException(
					"File widget cannot be updated by " + request.getMethod() + ".");
		}

		// Check only one file item in the request
		FileItem[] items = request.getFileItems(getId());
		if (items.length > 1) {
			throw new SystemException("More than one file item received on the request.");
		}

		// Check the client provided a fileID
		String fileId = request.getParameter(FILE_UPLOAD_MULTI_PART_ID_KEY);
		if (fileId == null) {
			throw new SystemException("No file id provided for file upload.");
		}

		// Wrap the file item
		FileItemWrap wrap = new FileItemWrap(items[0]);
		
		// if fileType is supplied then validate it
		if (hasFileTypes() && !FileUtil.validateFileType(wrap, getFileTypes())) {
			String invalidMessage = FileUtil.getInvalidFileTypeMessage(getFileTypes());
			throw new SystemException(invalidMessage);
		}

		// if fileSize is supplied then validate it
		if (hasMaxFileSize() && !FileUtil.validateFileSize(wrap, getMaxFileSize())) {
			String invalidMessage = FileUtil.getInvalidFileSizeMessage(getMaxFileSize());
			throw new SystemException(invalidMessage);
		}
		
		FileWidgetUpload file = new FileWidgetUpload(fileId, wrap);
		addFile(file);

		// Set the file id to be used ion the renderer
		setFileUploadRequestId(fileId);
		setNewUpload(true);
	}
889034
void processFormSubmitRequest(HttpServletRequest request) {

        String formDataId = getFormDataId(request);
        List<FileItem> items = CmsRequestUtil.readMultipartFileItems(request);
        m_storedFormData.put(formDataId, items);
    }
694144
private void addQueryParams(final Request request) {
        if (countryCode != null) {
            request.addQueryParam("CountryCode", countryCode);
        }

        if (type != null) {
            for (String prop : type) {
                request.addQueryParam("Type", prop);
            }
        }

        if (addOns != null) {
            for (String prop : addOns) {
                request.addQueryParam("AddOns", prop);
            }
        }

        if (addOnsData != null) {
            Map<String, String> params = PrefixedCollapsibleMap.serialize(addOnsData, "AddOns");
            for (Map.Entry<String, String> entry : params.entrySet()) {
                request.addQueryParam(entry.getKey(), entry.getValue());
            }
        }
    }
1229144
@SuppressWarnings("unchecked")
	public void open(File inputFile) throws IOException {
		deserializer = (Deserializer<OUT>) (readAsByteArray ? new ByteArrayDeserializer() : new TupleDeserializer());

		inputFile.getParentFile().mkdirs();

		if (inputFile.exists()) {
			inputFile.delete();
		}
		inputFile.createNewFile();
		inputRAF = new RandomAccessFile(inputFile, "rw");
		inputRAF.setLength(mappedFileSizeBytes);
		inputRAF.seek(mappedFileSizeBytes - 1);
		inputRAF.writeByte(0);
		inputRAF.seek(0);
		inputChannel = inputRAF.getChannel();
		fileBuffer = inputChannel.map(FileChannel.MapMode.READ_WRITE, 0, mappedFileSizeBytes);
	}
1060336
private void addPostParams(final Request request) {
        if (friendlyName != null) {
            request.addPostParam("FriendlyName", friendlyName);
        }

        if (awsCredentialsSid != null) {
            request.addPostParam("AwsCredentialsSid", awsCredentialsSid);
        }

        if (encryptionKeySid != null) {
            request.addPostParam("EncryptionKeySid", encryptionKeySid);
        }

        if (awsS3Url != null) {
            request.addPostParam("AwsS3Url", awsS3Url.toString());
        }

        if (awsStorageEnabled != null) {
            request.addPostParam("AwsStorageEnabled", awsStorageEnabled.toString());
        }

        if (encryptionEnabled != null) {
            request.addPostParam("EncryptionEnabled", encryptionEnabled.toString());
        }
    }
1292432
public void addFile(String path, InputStream inputStream) throws IOException {
    addFile(path, inputStream, null);
  }
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);
	}
1265209
private void addPostParams(final Request request) {
        if (body != null) {
            request.addPostParam("Body", body);
        }

        if (mediaUrl != null) {
            for (URI prop : mediaUrl) {
                request.addPostParam("MediaUrl", prop.toString());
            }
        }
    }
1208706
public static void setupRequestParameters(final HttpServletRequest request) {

		// Check already processed
		if (request.getAttribute(REQUEST_PROCESSED_KEY) != null) {
			return;
		}

		Map<String, String[]> parameters = new HashMap<>();
		Map<String, FileItem[]> files = new HashMap<>();

		extractParameterMap(request, parameters, files);

		request.setAttribute(REQUEST_PROCESSED_KEY, "Y");
		request.setAttribute(REQUEST_PARAMETERS_KEY, Collections.unmodifiableMap(parameters));
		request.setAttribute(REQUEST_FILES_KEY, Collections.unmodifiableMap(files));
	}