当前位置: 首页 > news >正文

江门网站建设总部电话wordpress添加悬浮按钮

江门网站建设总部电话,wordpress添加悬浮按钮,设计制作公益广告牌教案,wordpress这软件怎么搜索实际工作中#xff0c;需要用阿里云对象存储保存图片#xff0c;并且在上传图片到阿里云对象存储服务器后#xff0c;获取图片在阿里云对象存储服务器的URL地址#xff0c;以便给 WEB 前端显示。 阿里云对象存储上传图片的工具类 package zhangchao;import com.aliyun.os…实际工作中需要用阿里云对象存储保存图片并且在上传图片到阿里云对象存储服务器后获取图片在阿里云对象存储服务器的URL地址以便给 WEB 前端显示。 阿里云对象存储上传图片的工具类 package zhangchao;import com.aliyun.oss.ClientException; import com.aliyun.oss.OSS; import com.aliyun.oss.OSSClientBuilder; import com.aliyun.oss.OSSException; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.net.URL; import java.util.Date; import java.util.UUID;/*** 阿里云对象存储工具类*/ public class OSSUtils {// OSS阿里云对象存储的AK和SKprivate static final String OSS_AK yourAK;private static final String OSS_SK yourSK;// OSS阿里云对象存储的Bucket名称private static final String OSS_BUCKET_NAME your-files;// Endpoint以华东1杭州为例其它Region请按实际情况填写。private static final String OSS_ENDPOINT https://oss-cn-hangzhou.aliyuncs.com;/*** 上传图片并返回图片URL* return 图片URL*/public static String uploadImage(String imageFilePath) {String result null;// 创建OSSClient实例。OSS ossClient new OSSClientBuilder().build(OSS_ENDPOINT, OSS_AK, OSS_SK);FileInputStream fis null;try {// 创建存储空间。fis new FileInputStream(imageFilePath);String uuid UUID.randomUUID().toString().replaceAll(-, );ossClient.putObject(OSS_BUCKET_NAME, uuid, fis);// 设置URL过期时间为10年 3600l * 1000 * 24 * 365 * 10Date expiration new Date(System.currentTimeMillis() 3600L * 1000L *24L * 365L * 10L);URL url ossClient.generatePresignedUrl(OSS_BUCKET_NAME, uuid, expiration);if (url ! null) {result url.toString();}} catch (OSSException oe) {StringBuilder sb new StringBuilder();sb.append(Caught an OSSException, which means your request made it to OSS, ).append(but was rejected with an error response for some reason.);sb.append(Error Message:).append(oe.getErrorMessage());sb.append(Error Code:).append(oe.getErrorCode());sb.append(Request ID:).append(oe.getRequestId());sb.append(Host ID:).append(oe.getHostId());System.out.println(sb.toString());} catch (ClientException ce) {StringBuilder sb new StringBuilder();sb.append(Caught an ClientException, which means the client encountered ).append(a serious internal problem while trying to communicate with OSS, ).append(such as not being able to access the network.);sb.append(Error Message: ce.getMessage());System.out.println(sb.toString());ce.printStackTrace();} catch (FileNotFoundException e) {e.printStackTrace();} finally {try {if (null ! fis) {fis.close();}} catch (IOException e) {e.printStackTrace();}if (ossClient ! null) {ossClient.shutdown();}}return result;} } 调用的 main 方法 package zhangchao;public class Main {public static void main(String[] args) {String imgUrl OSSUtils.uploadImage(E:\\ws\\zc\\Java8OSSImg\\src\\main\\resources\\q1.jpg);System.out.println(imgUrl);} }运行结果这里显示了返回的图片 URL 地址 https://your-files.oss-cn-hangzhou.aliyuncs.com/abc123?Expires2021599742OSSAccessKeyIdyouAKSignaturexxxxxx这个地址没办法用浏览器直接看需要写个HTML来测试一下。 !DOCTYPE html html langen headmeta charsetUTF-8titleTitle/title /head bodyimg srchttps://your-files.oss-cn-hangzhou.aliyuncs.com/abc123?Expires2021599742OSSAccessKeyIdyouAKSignaturexxxxxx /body /html
http://www.zqtcl.cn/news/166883/

相关文章:

  • 网站流量如何增加提高工作效率的措施
  • 龙湖镇华南城网站建设.net 网站开发书籍
  • 域名费用和网站服务器费用是同样的吗推广营销方案
  • 安徽网站设计方案中文外贸网站有哪些
  • 衡阳手机网站设计响应式网站做多大的尺寸
  • 海尔电子商务网站建设预算灵台县门户网
  • 四川网站建设设计公司排名开发公司与建筑公司合作协议
  • 江西智能网站建设嘉定注册公司
  • 海口网站建设联系方式十大免费软文推广平台
  • 石碣镇做网站帮别人做网站开价
  • 站长 网站ip客户都不愿意做网站
  • 网站开发和软件开发哪个难网站备案账号
  • 2昌平区网站建设安徽盛绿建设网站
  • 商务网站建设目的天津建设网站需要的费用
  • flash 网站头部wordpress支持大文件上传
  • 网站开发方式的选择凡客设计
  • 常德建设网站如何查询某个网站的设计公司
  • wordpress 仿站教程学校ui设计培训
  • 南昌模板建站定制网站合肥瑶海区网站建设价格
  • 奥尔马手表官方网站导出wordpress文章
  • 网站栏目内容和功能手机网站建设 如何获得更好的排名
  • 网站运营推广难做常德网警
  • 北滘网站建设公司在百度上做网站怎么做
  • 合肥网站建设 毅耘园林设计网站大全
  • 免费备案网站空间爱营销app
  • 郑州网站建设公网站建设需要步骤
  • 源创派网站建设做软件赚钱的网站有哪些
  • 中英文网站建设公司推广引流
  • 网站改域名百度热词指数
  • 网站开发工程师工作内容网站源码是用什么做的