I've added a small entity:
entity Document {
name String,
file Blob
}
I've imported the jdl file, started the app and I've uploaded a PDF file. First thing when I browse the entity I see in the column FILE the link "Open", the type of file and the size of file. Is it not possible to get the file's name? Is it this information lost during the saving on the front-end or back-end? I see in the Document.java class an additional attribute FILE_CONTENT_TYPE. Maybe it would be useful to extend the entity with blob field with an attribute holding the file name?
But serious problem I have when I click on "Open" to retrieve a PDF file in Chrome. The browser first opens a new tab but this tab is empty. Firefox opens the file correctly in a new tab, Microsoft gives a possibility to save the file but prompts that is ".txt" file.
A possibility to handle (upload/download) various types of files is very important in my application which I try to build based on JHipster.
The last version of JHipster (5.3.4). I've added only this one entity.
5.3.4
{
"generator-jhipster": {
"promptValues": {
"packageName": "com.mycompany.myapp",
"nativeLanguage": "en"
},
"jhipsterVersion": "5.3.4",
"applicationType": "monolith",
"baseName": "test01",
"packageName": "com.mycompany.myapp",
"packageFolder": "com/mycompany/myapp",
"serverPort": "8080",
"authenticationType": "jwt",
"cacheProvider": "ehcache",
"enableHibernateCache": true,
"websocket": false,
"databaseType": "sql",
"devDatabaseType": "h2Disk",
"prodDatabaseType": "postgresql",
"searchEngine": false,
"messageBroker": false,
"serviceDiscoveryType": false,
"buildTool": "maven",
"enableSwaggerCodegen": false,
"clientFramework": "angularX",
"useSass": false,
"clientPackageManager": "npm",
"testFrameworks": [],
"jhiPrefix": "jhi",
"enableTranslation": true,
"nativeLanguage": "en",
"languages": [
"en",
"pl"
]
}
}
entityName.json
files generated in the .jhipster
directory{
"name": "Document",
"fields": [
{
"fieldName": "name",
"fieldType": "String"
},
{
"fieldName": "file",
"fieldType": "byte[]",
"fieldTypeBlobContent": "any"
}
],
"relationships": [],
"changelogDate": "20180929135217",
"entityTableName": "document",
"dto": "no",
"pagination": "no",
"service": "no",
"jpaMetamodelFiltering": false,
"fluentMethods": true,
"clientRootFolder": "",
"applications": "*"
}
Windows, Linux.
FILE_CONTENT_TYPE
That's quite some work to have all this, so I'm adding a "feature request" tag, but I'm not sure anybody will do this (as you are the first one asking) - @edvjacek would you be ready to contribute on this part? We would of course help you.
This could be done by adding a new FileBlob JDL type but as @jdubois said you will need to store the original name of the file and the Media Type (MIME type).
Also storing files in the database is not a great idea, what could be done is plugging Spring Data to an object storage using Spring Content (I think we add a feature request about this some time ago). Then during development, an S3 server can be easily bootstrapped with Minio.
I'm closing this as I don't think this will be done (we have higher priorities and @edvjacek didn't comment). Also, that's a lot of code to test and maintain, not sure this would be good for the project in the long run.
Most helpful comment
This could be done by adding a new FileBlob JDL type but as @jdubois said you will need to store the original name of the file and the Media Type (MIME type).
Also storing files in the database is not a great idea, what could be done is plugging Spring Data to an object storage using Spring Content (I think we add a feature request about this some time ago). Then during development, an S3 server can be easily bootstrapped with Minio.