Java Code Examples for com.qiniu.common.QiniuException#printStackTrace()
The following examples show how to use
com.qiniu.common.QiniuException#printStackTrace() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: QiniuUploadServiceImpl.java From mysiteforme with Apache License 2.0 | 6 votes |
@Override public Boolean delete(String path) { EntityWrapper<Rescource> wrapper = new EntityWrapper<>(); wrapper.eq("web_url",path); wrapper.eq("del_flag",false); wrapper.eq("source","qiniu"); Rescource rescource = rescourceService.selectOne(wrapper); path = rescource.getOriginalNetUrl(); try { getBucketManager().delete(getUploadInfo().getQiniuBucketName(), path); rescourceService.deleteById(rescource); return true; } catch (QiniuException e) { e.printStackTrace(); return false; } }
Example 2
Source File: QiniuFileUtil.java From mysiteforme with Apache License 2.0 | 6 votes |
/*** * 上传网络图片 * @param src * @return */ public static String uploadImageSrc(String src){ Zone z = Zone.zone0(); Configuration config = new Configuration(z); Auth auth = Auth.create(qiniuAccess, qiniuKey); BucketManager bucketManager = new BucketManager(auth, config); String fileName = UUID.randomUUID().toString(),filePath=""; try { FetchRet fetchRet = bucketManager.fetch(src, bucketName); filePath = path + fetchRet.key; Rescource rescource = new Rescource(); rescource.setFileName(fetchRet.key); rescource.setFileSize(new java.text.DecimalFormat("#.##").format(fetchRet.fsize/1024)+"kb"); rescource.setHash(fetchRet.hash); rescource.setFileType(fetchRet.mimeType); rescource.setWebUrl(filePath); rescource.setSource("qiniu"); rescource.insert(); } catch (QiniuException e) { filePath = src; e.printStackTrace(); } return filePath; }
Example 3
Source File: QiniuUtil.java From newblog with Apache License 2.0 | 6 votes |
public static void putFile(String bucket, String key, String filePath) { try { Response res = uploadManager.put(filePath, key, getToken(bucket)); if (!res.isOK()) { log.error("Upload to qiniu failed;File path: " + filePath + ";Error: " + res.error); } } catch (QiniuException e) { e.printStackTrace(); Response r = e.response; log.error(r.toString()); try { log.error(r.bodyString()); } catch (QiniuException e1) { log.error(e1.getMessage()); } } }
Example 4
Source File: QiniuUtil.java From newblog with Apache License 2.0 | 6 votes |
public static void putFile(String bucket, String key, File file) { try { // Response res = uploadManager.put(filePath, key, getToken(bucket)); Response res = uploadManager.put(file, key, getToken(bucket)); if (!res.isOK()) { log.error("Upload to qiniu failed;File path: " + file.getPath() + ";Error: " + res.error); } } catch (QiniuException e) { e.printStackTrace(); Response r = e.response; log.error(r.toString()); try { log.error(r.bodyString()); } catch (QiniuException e1) { log.error(e1.getMessage()); } } }
Example 5
Source File: QiniuUtil.java From newblog with Apache License 2.0 | 6 votes |
public static void putFileBytes(String bucket, String key, byte[] bytes) { try { // Response res = uploadManager.put(filePath, key, getToken(bucket)); Response res = uploadManager.put(bytes, key, getToken(bucket)); if (!res.isOK()) { log.error("Upload to qiniu failed;File path: " + ";Error: " + res.error); } } catch (QiniuException e) { e.printStackTrace(); Response r = e.response; log.error(r.toString()); try { log.error(r.bodyString()); } catch (QiniuException e1) { log.error(e1.getMessage()); } } }
Example 6
Source File: QiniuUtils.java From spring-admin-vue with Apache License 2.0 | 5 votes |
/** * 上传二进制数据,返回 文件的 UIR * * @param data * @param fileKey * @return String * @throws IOException */ public String upload(byte[] data, String fileKey) throws IOException { Response res; try { res = getUploadManager().put(data, fileKey, getUpToken(fileKey)); DefaultPutRet putRet = JsonUtils.jsonToPojo(res.body(), DefaultPutRet.class); return fileDomain + "/" + putRet.key; } catch (QiniuException e) { res = e.response; e.printStackTrace(); return "上传失败"; } }
Example 7
Source File: QiniuUtils.java From spring-admin-vue with Apache License 2.0 | 5 votes |
/** * 上传输入流,返回 文件的 UIR * * @param inputStream * @param fileKey * @return String * @throws IOException */ public String upload(InputStream inputStream, String fileKey) throws IOException { Response res; try { res = getUploadManager().put(inputStream, fileKey, getUpToken(fileKey), null, null); DefaultPutRet putRet = JsonUtils.jsonToPojo(res.body(), DefaultPutRet.class); return fileDomain + "/" + putRet.key; } catch (QiniuException e) { res = e.response; e.printStackTrace(); return "上传失败"; } }
Example 8
Source File: UploadConfiguration.java From spring-cloud-shop with MIT License | 5 votes |
/** * 字节数组上传 * * @param data 字节数组 * @param fileName 文件名 */ static String uploadToByte(byte[] data, String fileName) { UploadManager uploadManager = UploadConfiguration.getUploadManager(); try { Response response = uploadManager.put(data, fileName, UploadConfiguration.getToken()); if (response.isOK()) { DefaultPutRet putRet = JSON.parseObject(response.bodyString(), DefaultPutRet.class); return putRet.key; } } catch (QiniuException e) { e.printStackTrace(); } return null; }
Example 9
Source File: QiniuServiceImpl.java From spring-cloud-shop with MIT License | 5 votes |
@Override public String uploadToByte(byte[] data, String fileName) { try { Response response = uploadManager.put(data, fileName, this.getToken()); if (response.isOK()) { DefaultPutRet putRet = JSON.parseObject(response.bodyString(), DefaultPutRet.class); return putRet.key; } } catch (QiniuException e) { e.printStackTrace(); } return null; }
Example 10
Source File: QiniuUploadServiceImpl.java From mysiteforme with Apache License 2.0 | 5 votes |
@Override public String uploadNetFile(String url) throws IOException, NoSuchAlgorithmException { String fileName = RandomUtil.randomUUID(); EntityWrapper<Rescource> wrapper = new EntityWrapper<>(); wrapper.eq("source","qiniu"); wrapper.eq("original_net_url",url); wrapper.eq("del_flag",false); Rescource rescource = rescourceService.selectOne(wrapper); if(rescource != null){ return rescource.getWebUrl(); } StringBuffer key = new StringBuffer(); StringBuffer returnUrl = new StringBuffer(getUploadInfo().getQiniuBasePath()); try { String qiniuDir = getUploadInfo().getQiniuDir(); if(StringUtils.isNotBlank(qiniuDir)){ key.append(qiniuDir).append("/"); returnUrl.append(qiniuDir).append("/"); } key.append(fileName); returnUrl.append(fileName); FetchRet fetchRet = getBucketManager().fetch(url, getUploadInfo().getQiniuBucketName(),key.toString()); rescource = new Rescource(); rescource.setFileName(fetchRet.key); rescource.setFileSize(new java.text.DecimalFormat("#.##").format(fetchRet.fsize/1024)+"kb"); rescource.setHash(fetchRet.hash); rescource.setFileType(fetchRet.mimeType); rescource.setWebUrl(returnUrl.toString()); rescource.setSource("qiniu"); rescource.setOriginalNetUrl(url); rescource.insert(); } catch (QiniuException e) { e.printStackTrace(); } return returnUrl.toString(); }
Example 11
Source File: QiniuFileUtil.java From mysiteforme with Apache License 2.0 | 5 votes |
/*** * 删除已经上传的图片 * @param imgPath */ public static void deleteQiniuP(String imgPath) { Zone z = Zone.zone0(); Configuration config = new Configuration(z); Auth auth = Auth.create(qiniuAccess, qiniuKey); BucketManager bucketManager = new BucketManager(auth,config); imgPath = imgPath.replace(path, ""); try { bucketManager.delete(bucketName, imgPath); } catch (QiniuException e) { e.printStackTrace(); } }
Example 12
Source File: QiniuStorageManager.java From sanshanblog with Apache License 2.0 | 5 votes |
/** * 根据名字删除文件 */ public void ueditorDeleteFile(String filename) { Auth auth = Auth.create(accessKey, secretKey); BucketManager bucketManager = new BucketManager(auth, cfg); try { bucketManager.delete(ueditor_bucket,filename); } catch (QiniuException e) { //删除失败 log.error(e.getMessage()); e.printStackTrace(); } }