一个简单的demo,上传的时候根据你的阿里云更换相应的endpoint,accessKeyId,accessKeySecret和bucket name
package com;
import com.aliyun.oss.OSSClient;
import com.aliyun.oss.model.PutObjectResult;
import java.io.*;
/**
* Created by Administrator on 2016/10/19 0019.
*/
public class Test02 {
public static void main(String[] args) throws IOException {
// 华东2的endpoint
String endpoint = "http://oss-cn-shanghai.aliyuncs.com";
// accessKey请登录https://ak-console.aliyun.com/#/查看
String accessKeyId = "your accessKeyId";
String accessKeySecret = "your accessKeySecret";
// 创建OSSClient实例
OSSClient ossClient = new OSSClient(endpoint, accessKeyId, accessKeySecret);
// 上传文件流
// InputStream inputStream = new FileInputStream("C:\\Aliyun.png");
// System.out.println(ossClient.putObject("dajia-test-1", "1.txt", createSamp