Created
August 31, 2018 11:22
-
-
Save nOy39/03382ab10f9d7312f0f3daf077c97f59 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Request URL: http://localhost:8080/api/image | |
Request Method: POST | |
Status Code: 400 Bad Request | |
Remote Address: 127.0.0.1:8080 | |
Referrer Policy: no-referrer-when-downgrade | |
cache-control: no-cache, no-store, max-age=0, must-revalidate | |
connection: close | |
Content-Encoding: gzip | |
content-type: application/json;charset=UTF-8 | |
date: Fri, 31 Aug 2018 11:16:35 GMT | |
expires: 0 | |
pragma: no-cache | |
transfer-encoding: chunked | |
Vary: Accept-Encoding | |
x-content-type-options: nosniff | |
x-frame-options: DENY | |
X-Powered-By: Express | |
x-xss-protection: 1; mode=block | |
Accept: application/json, text/plain, */* | |
Accept-Encoding: gzip, deflate, br | |
Accept-Language: ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7 | |
Connection: keep-alive | |
Content-Length: 192033 | |
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryVAqhKEWcGn4s4Hq5 | |
Cookie: Webstorm-1325cb19=4812f0b8-65d2-4cf6-94c5-6ce0afc9f55e | |
Host: localhost:8080 | |
Origin: http://localhost:8080 | |
Referer: http://localhost:8080/test | |
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36 | |
------WebKitFormBoundaryVAqhKEWcGn4s4Hq5 | |
Content-Disposition: form-data; name="file"; filename="404.png" | |
Content-Type: image/png | |
------WebKitFormBoundaryVAqhKEWcGn4s4Hq5 | |
Content-Disposition: form-data; name="workers" | |
[object Object] | |
------WebKitFormBoundaryVAqhKEWcGn4s4Hq5-- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2018-08-31 13:16:35.610 WARN 12148 --- [nio-8000-exec-3] .w.s.m.s.DefaultHandlerExceptionResolver : | |
Failed to bind request element: org.springframework.web.method.annotation.MethodArgumentTypeMismatchException: | |
Failed to convert value of type 'java.lang.String' to required type 'org.a2lpo.workecontrol.dao.entities.Workers'; nested exception is org.springframework.core.convert.ConversionFailedException: | |
Failed to convert from type [java.lang.String] to type [java.lang.Long] for value '[object Object]'; nested exception is java.lang.NumberFormatException: For input string: "[objectObject]" | |
2018-08-31 13:16:35.611 WARN 12148 --- [nio-8000-exec-3] .w.s.m.s.DefaultHandlerExceptionResolver : | |
Resolved exception caused by Handler execution: org.springframework.web.method.annotation.MethodArgumentTypeMismatchException: | |
Failed to convert value of type 'java.lang.String' to required type 'org.a2lpo.workecontrol.dao.entities.Workers'; nested exception is org.springframework.core.convert.ConversionFailedException: | |
Failed to convert from type [java.lang.String] to type [java.lang.Long] for value '[object Object]'; nested exception is java.lang.NumberFormatException: For input string: "[objectObject]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data () { | |
return { | |
response: { | |
status: '', | |
config: { | |
baseUrl: '', | |
method: '' | |
} | |
}, | |
fileSelected: null, | |
workers: { | |
firstName: 'SomeFirstName', | |
lastName: 'SomeLastName', | |
job: 'SomeJob', | |
unit: 'SomeUnit' | |
} | |
} | |
}, | |
methods: { | |
onFileSelected (event) { | |
this.fileSelected = event.target.files[0] | |
}, | |
create () { | |
const formData = new FormData() | |
formData.append('file', this.fileSelected) | |
formData.append('workers', this.workers) | |
AXIOS.post('/image', formData, { | |
headers: { 'Content-Type': 'multipart/form-data' } | |
}) | |
.then(response => { | |
console.log(response) | |
}) | |
.catch(e => { | |
this.$store.dispatch('setError', e) | |
}) | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@PostMapping(value = "image") | |
public void addImage(@RequestParam("file") MultipartFile file, | |
@RequestParam("firstName") String firstName, | |
@RequestParam("lastName") String lastName, | |
@RequestParam("unit") String unit, | |
@RequestParam("job") String job) { | |
Workers workers = new Workers(); | |
workers.setPhotoFile(utilService.createFileName(file)); | |
workers.setFirstName(firstName); | |
workers.setLastName(lastName); | |
workers.setUnit(unit); | |
workers.setJob(job); | |
workersRepo.save(workers); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@PostMapping(value = "image") | |
public void addImage(@RequestParam("file") MultipartFile file, | |
@RequestParam("workers") Workers workers) { | |
workers.setPhotoFile(utilService.createFileName(file)); | |
workersRepo.save(workers); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data () { | |
return { | |
response: { | |
status: '', | |
config: { | |
baseUrl: '', | |
method: '' | |
} | |
}, | |
fileSelected: null, | |
firstName: 'SomeFirstName', | |
lastName: 'SomeLastName', | |
job: 'SomeJob', | |
unit: 'SomeUnit' | |
} | |
}, | |
methods: { | |
onFileSelected (event) { | |
this.fileSelected = event.target.files[0] | |
}, | |
create () { | |
const formData = new FormData() | |
formData.append('file', this.fileSelected) | |
formData.append('firstName', this.firstName) | |
formData.append('lastName', this.lastName) | |
formData.append('job', this.job) | |
formData.append('unit', this.unit) | |
AXIOS.post('/image', formData, { | |
headers: { 'Content-Type': 'multipart/form-data' } | |
}) | |
.then(response => { | |
console.log(response) | |
}) | |
.catch(e => { | |
this.$store.dispatch('setError', e) | |
}) | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment