七牛云
来源:互联网 发布:js string转date函数 编辑:程序博客网 时间:2024/06/05 02:45
http://jsfiddle.net/rwifeng/7rgqzpb0/3/#run token生成地址
public class QnUpDown { public static void init(){ Configuration config = new Configuration.Builder() .chunkSize(256 * 1024) //分片上传时,每片的大小。 默认256K .putThreshhold(512 * 1024) // 启用分片上传阀值。默认512K .connectTimeout(10) // 链接超时。默认10秒 .responseTimeout(60) // 服务器响应超时。默认60秒 .recorder(null) // recorder分片上传时,已上传片记录器。默认null .recorder(null, null) // keyGen 分片上传时,生成标识符,用于片记录器区分是那个文件的上传记录 .zone(null) // 设置区域,指定不同区域的上传域名、备用域名、备用IP。 .build(); // 重用uploadManager。一般地,只需要创建一个uploadManager对象 uploadManager = new UploadManager(config); } private static UploadManager uploadManager; /*上传文件*/ public static void upLoading(Context context){ File file =new File(context.getFilesDir(),"phoneX.jpg"); SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); String key = "icon_" + sdf.format(new Date()); String token = "iN7NgwM31j4-BZacMjPrOQBs34UG1maYCAQmhdCV:3j8sc3Hp280fBA87K25fyP8shSc" + "=:eyJzY29wZSI6InF0ZXN0YnVja2V0IiwiZGVhZGxpbmUiOjE0OTg3MzY5Mzd9"; uploadManager.put(file, key, token, new UpCompletionHandler() { @Override public void complete(String key, ResponseInfo info, JSONObject res) { //res包含hash、key等信息,具体字段取决于上传策略的设置 Logger.soutMessage(info.toString()); if (key!=null){ Logger.soutMessage(key.toString()); } if (res!=null){ Logger.soutMessage(res.toString()); } if(info.isOK()) { Logger.soutMessage("pass"); } else{ Logger.soutMessage("fail"); //如果失败,这里可以把info信息上报自己的服务器,便于后面分析上传错误原因 } Logger.soutMessage("finish"); } }, null); } public static boolean saveImage(Context context) { Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.g_a_axxhdpi); FileOutputStream outputStream; ByteArrayOutputStream out = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, out); try { out.flush(); // if (getisFirst()){ outputStream = context.openFileOutput("testb.jpg", Context.MODE_PRIVATE); /* }else { outputStream = openFileOutput("phoneY.jpg", Context.MODE_PRIVATE); }*/ out.writeTo(outputStream); out.close(); outputStream.close(); } catch (IOException e) { e.printStackTrace(); return false; } return true; }}
阅读全文
0 0
- 七牛云
- 七牛云笔试
- 七牛云存储
- 七牛云上传
- 初识七牛云
- 七牛云php
- 试用七牛云存储
- iOS七牛云存储
- ios 七牛云上传流程
- 七牛云存储刷新缓存
- 七牛云储存理解
- 七牛云存储使用笔记
- 七牛云存储上传文件
- IOS七牛云上传
- 七牛云清理缓存
- thinkphp5.0整合七牛云
- 七牛云java基础版本
- 七牛云上传图片
- MySQL(三)--类型属性
- Struts2的使用注解配置Action(零配置)
- 日常训练 IQ测试 可持久化数组||链表
- Git"Could not read from remote repository.Please make sure you have the correct access rights."解决方案
- WdatePicker日期插件的简单使用
- 七牛云
- MPAndroidChart绘制三角函数曲线
- 【Android】Uri、UriMatcher、ContentUris详解
- Maven的pom.xml文件结构之Build配置build
- 获取微信用户唯一标识openid | 小程序
- int 和 Integer 的区别与作用
- ubuntu中给pip设置代理的方法
- Android线程—生产者和消费者
- 深入 Java 调试体系