我试图通过Spring Boot设置文件上传REST API.
我目前有一个list/GET方法curl http://localhost:8080/api/aws/s3/list,它返回当前存在于存储桶中的对象列表.
对于上传,我一直在尝试:
curl -F "data=@test.txt" http://localhost:8080/api/aws/s3/upload -i
Run Code Online (Sandbox Code Playgroud)
哪个产生:
HTTP/1.1 100 Continue
HTTP/1.1 200 OK
Date: Sun, 25 Jun 2017 23:28:36 GMT
X-Application-Context: application
Content-Type: application/json;charset=utf-8
Transfer-Encoding: chunked
Run Code Online (Sandbox Code Playgroud)
但是,当我查看存储桶时,它尚未使用新文件进行更新.
这会是AWS上的权限问题吗?只有我的帐户具有读写权限.我创建的用户和组具有管理员权限.我没有添加Bucket Policy.这是我的CORS配置:
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>DELETE</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>Authorization</AllowedHeader>
</CORSRule>
</CORSConfiguration>
Run Code Online (Sandbox Code Playgroud)
这是我在春季的S3控制器的上传部分:
@RequestMapping(value = "/upload", method = RequestMethod.POST)
public List<PutObjectResult> upload(@RequestParam("file") MultipartFile[] multipartFiles) {
return s3Wrapper.upload(multipartFiles);
}
Run Code Online (Sandbox Code Playgroud) 我有一个spring-data-rest存储库,它产生一个hal + json对象,我希望我的Angular 2前端能够接收和显示.
Hal + Json对象:
{
"_embedded" : {
"users" : [ {
"name" : "Bob",
"_links" : {
"self" : {
"href" : "http://localhost:4200/api/users/1"
},
"user" : {
"href" : "http://localhost:4200/api/users/1"
}
}
}, {
"name" : "Joe",
"_links" : {
"self" : {
"href" : "http://localhost:4200/api/users/2"
},
"user" : {
"href" : "http://localhost:4200/api/users/2"
}
}
} ]
},
"_links" : {
"self" : {
"href" : "http://localhost:4200/api/users"
},
"profile" : {
"href" : "http://localhost:4200/api/profile/users"
},
"search" …Run Code Online (Sandbox Code Playgroud)