FileInputStream inFile = new FileInputStream("D:/project_list/splashnote08/src/webapp/resourcesDir/anonymousUser/123.jpg");
ByteArrayOutputStream outByteArray =
new ByteArrayOutputStream();
int i = -1;
while ((i = inFile.read())!=-1)
outByteArray.write((byte)i);
byte[] byteArray = outByteArray.toByteArray();
inFile.close();
outByteArray.close();
String filePath = S3Operations.upLoadObject("splashnote-test-bucket",byteArray,"1919.jpg");
System.out.println(filePath+"++++++++++++++++++++++");
File directiryPath = new File("D:/project_list/splashnote08/src/webapp/resourcesDir/anonymousUser");
if (!directiryPath.exists())
directiryPath.mkdirs();
directiryPath = new File("D:/project_list/splashnote08/src/webapp/resourcesDir/anonymousUser", "246.jpg");
OutputStream out = new FileOutputStream(directiryPath);
out.write(byteArray);
out.close();
这样有互了,在上传图片时,可以对图片做相应的处理.(例如,限制上传达室图片的大小.)