嗨我想将图像保存到s3但我最近完成了,上传图像时控制台上显示了一些警告。如何解决它.. 如果图像存在,我想替换图像
<bean id="projectDAO" class="com.startinpoint.proj.PMS.ProjectModule.ProjectDAOImpl">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<!-- Phase -->
<bean id="phaseBean" class="com.startinpoint.proj.PMS.PhaseModule.PhaseBean">
<property name="phaseManager" ref="phaseManager" />
</bean>
<bean id="phaseManager" class="com.startinpoint.proj.PMS.PhaseModule.PhaseManager">
<property name="phaseDAO" ref="phaseDAO" />
</bean>
<bean id="phaseDAO" class="com.startinpoint.proj.PMS.PhaseModule.PhaseDAOImpl">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<!-- Task -->
<bean id="taskBean" class="com.startinpoint.proj.PMS.TaskModule.TaskBean">
<property name="taskManager" ref="taskManager" />
</bean>
<bean id="taskManager" class="com.startinpoint.proj.PMS.TaskModule.TaskManager">
<property name="taskDAO" ref="taskDAO" />
</bean>
<bean id="taskDAO" class="com.startinpoint.proj.PMS.TaskModule.TaskDAOImpl">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
答案 0 :(得分:1)
您可以在Spring中使用本教程:依赖它。
private void saveImage(MultipartFile image) ImageUploadException {
try {
S3Bucket bucket = s3.getBucket("spittrImages");
S3Object imageObject = new S3Object(image.getOriginalFilename());
imageObject.setDataInputStream(image.getInputStream());
imageObject.setContentLength(image.getSize());
imageObject.setContentType(image.getContentType());
AccessControlList acl = new AccessControlList();
acl.setOwner(bucket.getOwner());
acl.grantPermission(GroupGrantee.ALL_USERS, Permission.PERMISSION_READ);
imageObject.setAcl(acl);
s3.putObject(bucket, imageObject);
} catch (Exception e) {
throw new ImageUploadException("Unable to save image", e);
}
}