Java Code Examples for org.camunda.bpm.engine.variable.value.FileValue#getEncoding()
The following examples show how to use
org.camunda.bpm.engine.variable.value.FileValue#getEncoding() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FileValueMapper.java From camunda-external-task-client-java with Apache License 2.0 | 6 votes |
public void writeValue(FileValue fileValue, TypedValueField typedValueField) { Map<String, Object> valueInfo = new HashMap<>(); valueInfo.put(VALUE_INFO_FILE_NAME, fileValue.getFilename()); if (fileValue.getEncoding() != null) { valueInfo.put(VALUE_INFO_FILE_ENCODING, fileValue.getEncoding()); } if (fileValue.getMimeType() != null) { valueInfo.put(VALUE_INFO_FILE_MIME_TYPE, fileValue.getMimeType()); } typedValueField.setValueInfo(valueInfo); byte[] bytes = ((FileValueImpl) fileValue).getByteArray(); if (bytes != null) { typedValueField.setValue(Base64.encodeBase64String(bytes)); } }
Example 2
Source File: FileValueTypeImpl.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Override public Map<String, Object> getValueInfo(TypedValue typedValue) { if (!(typedValue instanceof FileValue)) { throw new IllegalArgumentException("Value not of type FileValue"); } FileValue fileValue = (FileValue) typedValue; Map<String, Object> result = new HashMap<String, Object>(2); result.put(VALUE_INFO_FILE_NAME, fileValue.getFilename()); if (fileValue.getMimeType() != null) { result.put(VALUE_INFO_FILE_MIME_TYPE, fileValue.getMimeType()); } if (fileValue.getEncoding() != null) { result.put(VALUE_INFO_FILE_ENCODING, fileValue.getEncoding()); } if (fileValue.isTransient()) { result.put(VALUE_INFO_TRANSIENT, fileValue.isTransient()); } return result; }
Example 3
Source File: FileValueSerializer.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Override public void writeValue(FileValue value, ValueFields valueFields) { byte[] data = ((FileValueImpl) value).getByteArray(); valueFields.setByteArrayValue(data); valueFields.setTextValue(value.getFilename()); if (value.getMimeType() == null && value.getEncoding() != null) { valueFields.setTextValue2(MIMETYPE_ENCODING_SEPARATOR + value.getEncoding()); } else if (value.getMimeType() != null && value.getEncoding() == null) { valueFields.setTextValue2(value.getMimeType() + MIMETYPE_ENCODING_SEPARATOR); } else if (value.getMimeType() != null && value.getEncoding() != null) { valueFields.setTextValue2(value.getMimeType() + MIMETYPE_ENCODING_SEPARATOR + value.getEncoding()); } }
Example 4
Source File: VariableResponseProvider.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
/** * Creates a response for a variable of type {@link ValueType#FILE}. */ protected Response responseForFileVariable(FileValue fileValue) { String type = fileValue.getMimeType() != null ? fileValue.getMimeType() : MediaType.APPLICATION_OCTET_STREAM; if (fileValue.getEncoding() != null) { type += "; charset=" + fileValue.getEncoding(); } Object value = fileValue.getValue() == null ? "" : fileValue.getValue(); return Response.ok(value, type).header("Content-Disposition", "attachment; filename=\"" + fileValue.getFilename() + "\"").build(); }