Support > Repository > Model item > String - File

With the file type, you can handle images and documents.

An example

When you specify a file item, an input field as shown in Fig. 1 is prepared.

Figure 1 File field input field

- You can register files by dragging and dropping files to "Select files" button.R7.8

Figure 2 I dragged and dropped an image

On the detail display screen, the image is displayed as shown in Fig. 3.

Fig. 3 I registered an image

You can also register non-image files such as Word and Excel.Icons are displayed as shown in Fig. 4 on the detailed display screen.

Figure 4 I registered a Word document
Click on the icon to download the file.

Definition method

Select "File type" in the type detail setting of the string type item.

Figure 5 Specifying File Types

Search file name

When an item of "file name" type is set as a search condition, the file name is searched.Since it is treated as a string type, you can also specify a search method such as partial match, forward match.

Search contents of file

You can also search the contents of files such as Word, Excel, PowerPoint, and PDF. Please read "Full Text Search" for details.

For file items in the repeating container, you can register multiple files by dragging and dropping them all at once.The button name is "Select multiple files".

Figure 6 Button for selecting multiple files is prepared

I dragged and dropped two files.

Figure 7 I dragged and dropped two files

When you press the save button, "2 records" is registered in the repeating container part.In other words, it is registered as one record for each file.

Fig. 8 Registered as one record for each file

The Wagby file type has the following behavior.


Drag & drop behavior

Behavior varies depending on the browser.

browser Multiple file upload Drag and drop operation Bag ground upload
Google Chrome
IE 10
IE 11
Edge -
IE 9 or earlier
Other browsers
- - -

Internal structure

The file body is not stored in the database.A folder of model ID is prepared in the folder called upload_dir, and temporary file name is added to it and it is saved.

Figure 9 upload_dir Folder

When you create a file type item, there are two items in the corresponding (database) table.Here is an example.

Suppose you prepare a file type field photo for model product.At this time, the table product is created, but two items are prepared as follows.

item name Description An example
photo The file name is stored. duke3D.jpg
photo_jshfilename Indicates the path where the file exists.The starting point is wagbyapp/bin. ../../upload_dir/product/__multi1869501174086226700.tmp
In this example, the actual file stored in upload_dir is temporary file name (extension tmp).You can also use the uploaded file name itself.It is explained in the next section.

The entity of the uploaded file is stored in the upload_dir folder.The file name is internally changed mechanically, and the extension is ".tmp".(FIG. 10)

You can select this rule from the following three types by specifying "real file name saved in server" in "screen> others> file name type item".

(When blank)
The file name is given mechanically.The extension is .tmp.(standard)
File name is unique, extension is maintained
The file name is given mechanically, but the extension follows the uploaded file.
Use original file name as it is
Use the same file name and extension as the uploaded file.
Figure 10 File save settings

Figure 11 shows the upload_dir folder when "Use original file name as is" is set.It is stored as the file name at upload.

Figure 11 Contents of upload_dir folder when original file name is used as is

Notes on "Use original file name as is" setting

  • In the production environment (server), you need to use an OS that can handle Japanese names (eg Windows OS).
  • When using target items as search criteria, please distinguish between full-width and half-width characters and use them.Input filter is not applied.(Filter is internally forced to "character string (minimum)".)
  • When a file of the same name is registered when using the original file name, a suffix is ​​automatically assigned to distinguish file names as "_ 1", "_ 2", "_ 3", ....

When changing file name handling to "leave original file name" method during operation

If you change the settings so as to change the settings so that "use the original file name as the file name as it is" after operation, and rebuild the application, replacing the application will be as follows.

  • The file registered up to that point remains the file name with extension .tmp.
  • Files registered after application swapping are saved as original file names.

We provide a tool for restoring the name of the .tmp file registered in the past to the original file name. For details, please read "Change file name handling to method to leave original file name".

In Wagby, when you define an item of file type, two columns are prepared in the table.

  • In the first column, save the original file name.
  • In the other column, record the physical file name in the upload_dir folder.

Handling of entities of files

When file deletion processing is carried out, the file name information is deleted from the database, but the entity of the file remains.If you set the file name to use the original file name as it is, it will be overwritten by uploading the file with the same name.

The reason for leaving the entity of the file in the upload_dir folder is as follows.

  • In the case of using the copy registration function, it is necessary to prevent that the entity of the file no longer exists from the data copied when the copy source data is deleted.
  • In the case of reference linkage of the file type item and the self model saving, it is necessary to perform double management of the file at the interlocking source and the interworking destination.Even if the linkage source is copied, the entity of the file to be referenced from the interworking destination needs to remain.

Periodically delete physical files

There is a job to periodically delete the (remaining) entity of the file. "Support> Administrator Guide (R7)> Delete unreferenced file deletion job" Please read.

Delete physical files at the same time 7.11.2

There is also a method of deleting the entity of the file at the timing of data deletion.Please do this only if it does not correspond to "the reason to leave the entity of the file in the upload_dir folder".

Include the following contents in the context-param specification in the $ (APPHOME) \ webapps \ $ (APPNAME) \ webpage \ WEB-INF \ web.xml file that is the post-build application.


After adding the above setting, restart the application.This setting applies to the entire application.

By saving the edited web.xml file in the $ (DEVHOME) \ customize \ webapp \ WEB - INF folder, this file will be reflected (overwritten) in subsequent build processing.
If you change the web.xml file during operation, file deletion processing will work with the operation after changing (and restarting).However, the file before the change remains in the upload_dir folder.For historical data, search the file type items stored in the table directly with SQL and manually delete unreferenced files.


It does not correspond to list update, upload update, bulk update, mail reception, file deletion in mail transmission.Also, when using Dao/Service with customization code, it is not supported yet.These are plans to cope with future Wagby.

An example

You can specify the width and height of the image on the detailed display screen and the list display screen respectively.(FIGS. 12 and 13)

The image size of the detailed display screen was 32 pixels wide
Fig. 13 The image size of the list display screen was 32 pixels wide

Definition method

Select the output control tab of model item detail definition.Specify "image size" on the detail screen and the tab of the list screen.The unit is pixel.Both width and height can be specified, but when one is specified, the other is automatically adjusted while maintaining the ratio.

Figure 14 Specifying the image size width of the detail screen
Figure 15 Specifying the image size width of the list screen

An example

You can hide the file name.(Figure 16)

Figure 16 Hiding file names

Definition method

Select the output control tab of model item detail definition.Uncheck "Show file name (URL)" on tabs of detailed screen and list screen.(It is checked by standard.)

Figure 17 Uncheck the Show file name,

Specify file size

You can specify the minimum size and maximum size of the file to be uploaded.The unit is "Byte".

Figure 21 Make the file size range from 1 megabyte to 100 megabytes

If it is less than the specified size or exceeds the specified size, an error message like the one shown in Fig. 22 will be displayed.

Figure 22 Size Error
When specifying the size, you can also specify with "K" or "M".(Uppercase and lowercase letters are not distinguished.) 1K is 1024 bytes, 1M is 1024 Kbytes.
Only numeric sizes can be used for integer type.Decimal points can not be used.

Specify file extension

You can specify the extension of the file to be uploaded.Separate multiple items with a comma ",".

Figure 23 Only file extensions png and jpg are allowed

If it is not an acceptable file extension, an error message like the one shown in Figure 24 is displayed.

Figure 24 Extension error
In the above example, PNG and JPG are also allowed.Capital letters and lower case letters are not distinguished.

Open the automatically generated WEB-INF \ classes \ file with a text editor. It is described as follows.

# ライセンスファイル
# メールテンプレート
# 帳票テンプレート
# 顧客

By default, it is relative to the origin directory (wagbyapp \ bin).The save destination can be specified for each model.

Here, edit only the models that you want to change, leaving entries.For models that do not require change, delete the description from the original file. For example, if you only want to change the storage location for the "customer" model, it will be as follows.

# 顧客

Save the edited file in the customize \ resources folder with the filename

Changes after starting operation

If you create the file during operation, the following rule will be taken.

  • For files registered before change, refer to the folder specified before change.
  • For files registered after change, refer to the newly specified folder.
For this reason, please be careful not to erase the folder specified before change.

Other information

"Support> Wagby Developer Network (R7)> Customizing with Java> Resource file".

When you click on the file registered in the file type item to download it, the log is output.

2016-xx-xx 00:01:02 [INFO wagbyDownload2 _jspService] (admin) Download test.xls
  • For image files, logs are not output.(If the file extension is jpg/jpeg/png/gif/bmp, interpret it as an image file.)
  • When you click on the file, a dialog may be displayed asking whether you want to download.The log is output at that time.Therefore, even if you cancel (download) it will be recorded as downloaded on the log.
  • Even if you open it with the specified application, not download it will be recorded as downloaded on the log.

R7.12 or later

When the type name of MIME type is text (text file, HTML file etc), "utf - 8" is the standard for character encoding.

You can also change the standard character encoding by specifying "environment> application> initial parameter> character encoding of download file".This will be unified throughout the project.

Figure 25 Character Encoding of Download File

Before R7.12

The standard for character encoding is Shift_JIS.You can not change this.