This is an automated email from the ASF dual-hosted git repository.
mridulpathak pushed a commit to branch release24.09
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git
The following commit(s) were added to refs/heads/release24.09 by this push:
new 409167c34a Keep DataResource mimeTypeId when an upload has no content
type
409167c34a is described below
commit 409167c34a9e02cf93b95f64044b0ad0f0a70d4b
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 36c7ed1fde..97a0da4b46 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
@@ -262,7 +262,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 ?
@@ -306,7 +306,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)