调用代码示例
import java.io.File;
import java.util.HashMap;
import com.youku.uploader.FileUtil;
import com.youku.uploader.YoukuUploader;
/**
* web开发技术提供
* 网址:
* http://www.webkfa.com
*/
public class Test {
private static YoukuUploader uploader;
public static void main(String[] args) {
String client_id = ""; //OpenAPI client_id
String client_secret = ""; //OpenAPI client_secret
String username = ""; //Youku username or email
String password = ""; //youku password
String result = "";
String access_token = "";
HashMap<String, String> params, uploadInfo;
String filename = "";
File uploadFile = new File(filename);
byte[] data = FileUtil.getBytesFromFile(uploadFile); // 待上传文件字节数组
params = new HashMap<String, String>();
params.put("username", username);
params.put("password", password);
params.put("access_token", access_token);
uploadInfo = new HashMap<String, String>();
uploadInfo.put("file_name", filename); // 指定:文件名
uploadInfo.put("title", ""); // 指定:标题
uploadInfo.put("tags", ""); // 指定:分类
uploader = new YoukuUploader(client_id, client_secret);
result = uploader.upload(params, uploadInfo, data, false);
System.out.print(result);
}
}