You can manipulate the values ​​of file type items. R7.5

You can use multipart/form-data.Specifically, specify enctype = "multipart/form-data" on the form element.

How to use

Here, we will explain it using the sample model model 1 shown in Fig.The filename 1 item, cont/cfilename item is a file type item.

Figure 1 Sample model

When updating data whose value of the primary key item pkey is 1000, it becomes as follows.

1. Logon

PUT
http://localhost:8921/wagby/rest/session

Parameter: in x - www - form - urlencoded format
user=xxx
pass=xxx
I will send you.If successful, you can retrieve information on logged on account as JSON data.

2. Start updating

GET
http://localhost:8921/wagby/rest/model1/edit/1000

There is no parameter.If it succeeds, data to be updated can be acquired with JSON data.

3. Update execution

PUT
http://localhost:8921/wagby/rest/model1/edit

Parameters model1_p $ 002ffilename1 and model1_p $ 002fcont $ 005b1 $ 005d $ 002fcfilename is a file item so specify the file body in multipart format.

You can check these key names by looking at the HTML source of the update screen.

model1_p$002fpkey	1000
model1_p$002fcontent	aaa
model1_p$002ffilename1	ファイルを指定
model1_p$002fcont$005b1$005d$002fcid	1
model1_p$002fcont$005b1$005d$002fccontent	aaa
model1_p$002fcont$005b1$005d$002fcfilename	ファイルを指定

If it succeeds, data to be updated can be acquired with JSON data.
Figure 2 shows a screen confirming this call with the tool POSTMAN.

Fig.2 Interaction by POSTMAN

I will explain how to individually specify them using JSON objects.

Upload update screen file

Update the file type item on the maintenance screen.

@RequestMapping(value="/rest/[modelid]/edit/file/{modelitem}", method = POST, headers="Content-Type=multipart/form-data")

URL Example

http://localhost:8921/wagby/rest/model1/edit/file/filename1

Access by POST, send files in multipart.The file is specified by key name file. The uploaded file is set up.

Usage Considerations

It must be called after updating starts.It will be saved after updating.

Handling file type items in repeating containers

When specifying a repeating container, it is as follows.

Example: Specify the cfilename item of the first container of the repeating container cont.

http://localhost:8921/wagby/rest/model1/edit/file/cont/1/cfilename

Delete update screen file

Delete the file type item on the update screen.

@RequestMapping(value="/rest/[modelid]/edit/file/{modelitem}", method = DELETE)

URL Example

http://localhost:8921/wagby/rest/model1/edit/file/filename1

Access by DELETE.The file of the specified item is deleted.

Usage Considerations

It must be called after updating starts.It will be saved after updating.

Handling file type items in repeating containers

It is the same specification as "Upload update screen file".

Download update screen file

Download the file type item on the update screen.

@RequestMapping(value="/rest/[modelid]/edit/file/{modelitem}", method = GET)

URL Example

http://localhost:8921/wagby/rest/model1/edit/file/filename1

Access by GET.You can download the file of the specified item.

Usage Considerations

It must be called after updating starts.It will be saved after updating.

Handling file type items in repeating containers

It is the same specification as "Upload update screen file".

Upload new registration screen file

Upload the file type item on the new registration screen.

@RequestMapping(value="/rest/[modelid]/new/file/{modelitem}", method = POST, headers="Content-Type=multipart/form-data")

URL Example

http://localhost:8921/wagby/rest/model1/new/file/filename1

I will access it by POST.Send the file in multipart.The file is specified by key name file. The uploaded file is set up.

Usage Considerations

It is necessary to call it after starting new registration.It is saved after new registration is executed.

Handling file type items in repeating containers

When specifying a repeating container, it is as follows.

Example: Specify the cfilename item of the first container of the repeating container cont.

http://localhost:8921/wagby/rest/model1/new/file/cont/1/cfilename

Delete new registration screen file

Delete the file type item on the new registration screen.

@RequestMapping(value="/rest/[modelid]/new/file/{modelitem}", method = DELETE)

URL Example

http://localhost:8921/wagby/rest/model1/new/file/filename1

Access by DELETE.The file of the specified item is deleted.

Usage Considerations

It is necessary to call it after starting new registration.It is saved after new registration is executed.

Handling file type items in repeating containers

It is the same specification as "Upload new registration screen file".

Download of new registration screen file

Download the file type item on the new registration screen.

@RequestMapping(value="/rest/[modelid]/new/file/{modelitem}", method = GET)

URL Example

http://localhost:8921/wagby/rest/model1/new/file/filename1

Access by GET.You can download the file of the specified item.

Usage Considerations

It is necessary to call it after starting new registration.It is saved after new registration is executed.

Handling file type items in repeating containers

It is the same specification as "Upload new registration screen file".

Detailed screen file download

Download the file type item on the detail screen.

@RequestMapping(value="/rest/[modelid]/entry/{pkey}/file/{modelitem}", method = GET)

URL Example

http://localhost:8921/wagby/rest/model1/entry/1000/file/filename1

Access by GET.You can download the file of the specified item.

Handling file type items in repeating containers

It is the same specification as "Upload update screen file".