This is an automated email from the ASF dual-hosted git repository.
mridulpathak pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git
The following commit(s) were added to refs/heads/trunk by this push:
new 18bd601c03 Keep DataResource mimeTypeId when an upload has no content
type
18bd601c03 is described below
commit 18bd601c03d311f9f0962dd00801b9f97079a7d5
Author: Mridul Pathak <[email protected]>
AuthorDate: Thu Oct 22 22:16:29 2026 +0530
Keep DataResource mimeTypeId when an upload has no content type
saveLocalFileDataResource and saveExtFileDataResource assigned the uploaded
content type to mimeTypeId unconditionally. The minilang set skipped a null
source, so an upload without a content type kept the stored mimeTypeId, for
example the one createDataResource derived from the file bytes, while the
Groovy assignment stored null. The content type is now only assigned when it is
present.
---
.../groovy/org/apache/ofbiz/content/data/DataServicesScript.groovy | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git
a/applications/content/src/main/groovy/org/apache/ofbiz/content/data/DataServicesScript.groovy
b/applications/content/src/main/groovy/org/apache/ofbiz/content/data/DataServicesScript.groovy
index a4f3566fa1..906b2723e9 100644
---
a/applications/content/src/main/groovy/org/apache/ofbiz/content/data/DataServicesScript.groovy
+++
b/applications/content/src/main/groovy/org/apache/ofbiz/content/data/DataServicesScript.groovy
@@ -254,7 +254,7 @@ Map saveLocalFileDataResource(String mode) {
.where('mimeTypeId', parameters._uploadedFile_contentType)
.queryFirst()
dataResource.dataResourceName = parameters._uploadedFile_fileName
- if (mode in ['OFBIZ_FILE', 'OFBIZ_FILE_BIN', 'CONTEXT_FILE',
'CONTEXT_FILE_BIN']) {
+ if (mode in ['OFBIZ_FILE', 'OFBIZ_FILE_BIN', 'CONTEXT_FILE',
'CONTEXT_FILE_BIN'] && parameters._uploadedFile_contentType != null) {
dataResource.mimeTypeId = parameters._uploadedFile_contentType
}
dataResource.objectInfo = extension ?
@@ -298,7 +298,9 @@ Map saveExtFileDataResource(boolean isUpdate, String mode) {
// update the data resource with file data
dataResource.dataResourceTypeId = parameters.dataResourceTypeId
dataResource.dataResourceName = parameters._uploadedFile_fileName
- dataResource.mimeTypeId = parameters._uploadedFile_contentType
+ if (parameters._uploadedFile_contentType != null) {
+ dataResource.mimeTypeId = parameters._uploadedFile_contentType
+ }
dataResource.store()
Map serviceContext = prepareServiceContext(dataResource, mode)