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

河源建设工程交易中心网站优秀的营销策划案例

河源建设工程交易中心网站,优秀的营销策划案例,模板王字库,工程建设信息网站Java系列文章目录 文章目录 Java系列文章目录一、前言二、学习内容:三、问题描述四、解决方案:4.1 新建空间4.2 查找密钥4.3 进入开发者中心查找JavaSDK文档4.4 查找文件上传方法4.5 运行测试 五、总结:5.1 学习总结: 一、前言 学…

Java系列文章目录


文章目录

  • Java系列文章目录
  • 一、前言
  • 二、学习内容:
  • 三、问题描述
  • 四、解决方案:
    • 4.1 新建空间
    • 4.2 查找密钥
    • 4.3 进入开发者中心查找JavaSDK文档
    • 4.4 查找文件上传方法
    • 4.5 运行测试
  • 五、总结:
    • 5.1 学习总结:

一、前言

  • 学习七牛云的使用

二、学习内容:

  • 七牛云使用步骤

三、问题描述

七牛云文档使用


四、解决方案:

4.1 新建空间

在这里插入图片描述

4.2 查找密钥

在这里插入图片描述

4.3 进入开发者中心查找JavaSDK文档

在这里插入图片描述

4.4 查找文件上传方法

其他使用方法类似

注意引入相关依赖

在这里插入图片描述
参考代码:

//构造一个带指定 Region 对象的配置类
Configuration cfg = new Configuration(Region.region0());
cfg.resumableUploadAPIVersion = Configuration.ResumableUploadAPIVersion.V2;// 指定分片上传版本
//...其他参数参考类注释UploadManager uploadManager = new UploadManager(cfg);
//...生成上传凭证,然后准备上传
String accessKey = "your access key";
String secretKey = "your secret key";
String bucket = "your bucket name";
//如果是Windows情况下,格式是 D:\\qiniu\\test.png
String localFilePath = "/home/qiniu/test.png";
//默认不指定key的情况下,以文件内容的hash值作为文件名
String key = null;Auth auth = Auth.create(accessKey, secretKey);
String upToken = auth.uploadToken(bucket);try {Response response = uploadManager.put(localFilePath, key, upToken);//解析上传成功的结果DefaultPutRet putRet = new Gson().fromJson(response.bodyString(), DefaultPutRet.class);System.out.println(putRet.key);System.out.println(putRet.hash);
} catch (QiniuException ex) {ex.printStackTrace();if (ex.response != null) {System.err.println(ex.response);try {String body = ex.response.toString();System.err.println(body);} catch (Exception ignored) {}}
}

4.5 运行测试

  • 输入地址localhost:8080/doc.html打开文档
  • 运行后上传测试如果成功进入空间即可查看

使用knif4j测试

在这里插入图片描述


五、总结:

5.1 学习总结:

  • 有很多传递方法

在这里插入图片描述
第一种方法:

    //构造一个带指定 Region 对象的配置类Configuration cfg = new Configuration(Region.region0());cfg.resumableUploadAPIVersion = Configuration.ResumableUploadAPIVersion.V2;// 指定分片上传版本
//...其他参数参考类注释UploadManager uploadManager = new UploadManager(cfg);
//...生成上传凭证,然后准备上传String accessKey = "";String secretKey = "";String bucket = "";// 设置上传的存储区域//默认不指定key的情况下,以文件内容的hash值作为文件名String key = null;LocalDate now = LocalDate.now();DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");String format = now.format(formatter);String originalFilename = file.getOriginalFilename();String extend = originalFilename.substring(originalFilename.lastIndexOf("."));String fileName = format+ UUID.randomUUID().toString().replace("-","") +extend;try {InputStream inputStream = file.getInputStream();Auth auth = Auth.create(accessKey, secretKey);String upToken = auth.uploadToken(bucket);try {Response response = uploadManager.put(inputStream, fileName, upToken,null,null);//解析上传成功的结果DefaultPutRet putRet = JSON.parseObject(response.bodyString(),DefaultPutRet.class);System.out.println("http://scw897cq.hd-bkt.clouddn.com/"+putRet.key);//如果putRet.key的值是example.jpg,那么输出的URL将是http://scw897cq.hd-bkt.clouddn.com/example.jpg。你可以通过这个URL在浏览器或其他客户端直接访问或下载这个文件。System.out.println(putRet.hash);} catch (QiniuException ex) {ex.printStackTrace();if (ex.response != null) {System.err.println(ex.response);try {String body = ex.response.toString();System.err.println(body);} catch (Exception ignored) {}}}} catch (UnsupportedEncodingException ex) {//ignore}return "success";}

文档中的方法:

//构造一个带指定 Region 对象的配置类
Configuration cfg = new Configuration(Region.region0());
cfg.resumableUploadAPIVersion = Configuration.ResumableUploadAPIVersion.V2;// 指定分片上传版本
//...其他参数参考类注释UploadManager uploadManager = new UploadManager(cfg);
//...生成上传凭证,然后准备上传
String accessKey = "your access key";
String secretKey = "your secret key";
String bucket = "your bucket name";
//如果是Windows情况下,格式是 D:\\qiniu\\test.png
String localFilePath = "/home/qiniu/test.png";
//默认不指定key的情况下,以文件内容的hash值作为文件名
String key = null;Auth auth = Auth.create(accessKey, secretKey);
String upToken = auth.uploadToken(bucket);try {Response response = uploadManager.put(localFilePath, key, upToken);//解析上传成功的结果DefaultPutRet putRet = new Gson().fromJson(response.bodyString(), DefaultPutRet.class);System.out.println(putRet.key);System.out.println(putRet.hash);
} catch (QiniuException ex) {ex.printStackTrace();if (ex.response != null) {System.err.println(ex.response);try {String body = ex.response.toString();System.err.println(body);} catch (Exception ignored) {}}
}

区别如下:
文件来源:

  • 第一段代码使用MultipartFile接口从HTTP请求中获取文件,这通常是在Web应用中接收前端上传的文件的方式。
  • 第二段代码直接使用本地文件路径localFilePath来指定要上传的文件,这种方式适用于上传本地文件系统中的文件。

文件处理方式:

  • 第一段代码中,文件被转换为InputStream,并通过file.getInputStream()获取输入流。
  • 第二段代码中,直接使用文件路径localFilePath来上传文件。

JSON 解析库:

  • 第一段代码使用com.alibaba.fastjson2.JSON来解析响应体。
  • 第二段代码使用com.google.gson.Gson来解析响应体。

文件名生成:

  • 第一段代码根据当前日期和随机UUID生成文件名,并保留原始文件扩展名。
  • 第二段代码没有显示文件名生成逻辑,而是使用默认行为,即如果未指定key则使用文件内容的哈希值作为文件名。

注意引入依赖

参考依赖:

<dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>com.qiniu</groupId><artifactId>qiniu-java-sdk</artifactId><version>[7.13.0, 7.13.99]</version></dependency><!-- https://mvnrepository.com/artifact/com.alibaba.fastjson2/fastjson2 --><dependency><groupId>com.alibaba.fastjson2</groupId><artifactId>fastjson2</artifactId><version>2.0.49</version></dependency><dependency><groupId>com.google.code.gson</groupId><artifactId>gson</artifactId><version>2.8.9</version></dependency><dependency><groupId>com.github.xiaoymin</groupId><artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId><version>4.4.0</version></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><optional>true</optional></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency>
</dependencies>

声明:如本内容中存在错误或不准确之处,欢迎指正。转载时请注明原作者信息(麻辣香蝈蝈)。


文章转载自:
http://dinncometayer.ssfq.cn
http://dinncodsn.ssfq.cn
http://dinncoburgeon.ssfq.cn
http://dinncotrendsetting.ssfq.cn
http://dinncophotodramatist.ssfq.cn
http://dinncosolitudinarian.ssfq.cn
http://dinncoroorbach.ssfq.cn
http://dinncocommonly.ssfq.cn
http://dinnconowhere.ssfq.cn
http://dinncomediocritize.ssfq.cn
http://dinncomotoneurone.ssfq.cn
http://dinncoriver.ssfq.cn
http://dinncoqn.ssfq.cn
http://dinncocentralism.ssfq.cn
http://dinncoelectromagnetic.ssfq.cn
http://dinncoaftergrowth.ssfq.cn
http://dinncobastaard.ssfq.cn
http://dinncophilanthropy.ssfq.cn
http://dinncopulmonic.ssfq.cn
http://dinncoepilator.ssfq.cn
http://dinncogladius.ssfq.cn
http://dinncoheterotopism.ssfq.cn
http://dinncoimpureness.ssfq.cn
http://dinncoseditious.ssfq.cn
http://dinncoshoshonean.ssfq.cn
http://dinnconaseberry.ssfq.cn
http://dinncocageling.ssfq.cn
http://dinncohaustellate.ssfq.cn
http://dinncoenregiment.ssfq.cn
http://dinncolapsuslinguae.ssfq.cn
http://dinncoliterati.ssfq.cn
http://dinncocivilizable.ssfq.cn
http://dinncoemmer.ssfq.cn
http://dinncoedibility.ssfq.cn
http://dinncojovially.ssfq.cn
http://dinncodisheveled.ssfq.cn
http://dinncoveneration.ssfq.cn
http://dinncohitachi.ssfq.cn
http://dinncocopremic.ssfq.cn
http://dinncocacodemon.ssfq.cn
http://dinncocabinet.ssfq.cn
http://dinncoavoir.ssfq.cn
http://dinncomoderatist.ssfq.cn
http://dinncoscousian.ssfq.cn
http://dinncoboehmenism.ssfq.cn
http://dinncoluton.ssfq.cn
http://dinncoeccentricity.ssfq.cn
http://dinncojemadar.ssfq.cn
http://dinncotrice.ssfq.cn
http://dinncopoh.ssfq.cn
http://dinncotatou.ssfq.cn
http://dinncoheartache.ssfq.cn
http://dinncoconfiture.ssfq.cn
http://dinncomender.ssfq.cn
http://dinncoisoelectronic.ssfq.cn
http://dinncortty.ssfq.cn
http://dinncomyeloblast.ssfq.cn
http://dinncobeige.ssfq.cn
http://dinncoviscacha.ssfq.cn
http://dinncounstrained.ssfq.cn
http://dinncocarbo.ssfq.cn
http://dinncochutist.ssfq.cn
http://dinncosponginess.ssfq.cn
http://dinncomisguided.ssfq.cn
http://dinncobearward.ssfq.cn
http://dinnconeorican.ssfq.cn
http://dinncobryophyte.ssfq.cn
http://dinncoposttraumatic.ssfq.cn
http://dinncotapir.ssfq.cn
http://dinncophlebotomist.ssfq.cn
http://dinncovirtuoso.ssfq.cn
http://dinncorehydrate.ssfq.cn
http://dinncounnoticed.ssfq.cn
http://dinncohydromancer.ssfq.cn
http://dinncozoetrope.ssfq.cn
http://dinncogleichschaltung.ssfq.cn
http://dinncoupcoil.ssfq.cn
http://dinncohandball.ssfq.cn
http://dinncogiglet.ssfq.cn
http://dinncontsc.ssfq.cn
http://dinncocontrariously.ssfq.cn
http://dinncokernite.ssfq.cn
http://dinncoeuchre.ssfq.cn
http://dinncograveward.ssfq.cn
http://dinncodisagreeables.ssfq.cn
http://dinncogloze.ssfq.cn
http://dinncoperspiration.ssfq.cn
http://dinncosic.ssfq.cn
http://dinncoflake.ssfq.cn
http://dinncospecialization.ssfq.cn
http://dinncosolidly.ssfq.cn
http://dinncotapster.ssfq.cn
http://dinncopsychologise.ssfq.cn
http://dinncoftp.ssfq.cn
http://dinncocumulate.ssfq.cn
http://dinncodemythify.ssfq.cn
http://dinncoahasuerus.ssfq.cn
http://dinncootosclerosis.ssfq.cn
http://dinncorecur.ssfq.cn
http://dinncotrepid.ssfq.cn
http://www.dinnco.com/news/108079.html

相关文章:

  • 汽车网站模板短信广告投放软件
  • 毕设做网站需要什么技术准备制作网页完整步骤代码
  • 北京便宜做网站廊坊网络推广优化公司
  • 网站建设要实现的目标销售管理怎么带团队
  • 让网站建设便宜到底seo推广服务哪家好
  • wordpress视频网站北京优化推广
  • 贵阳网站建设宏思锐达东莞快速排名
  • 网站制作软件工程师客户管理软件
  • 无锡市建设局网站谷歌浏览器 官网下载
  • 网站制作自己接单seo网络推广优势
  • 嵊州网站建设搜索引擎优化seo什么意思
  • 深圳做网站联雅香港服务器
  • 织梦网站被做跳转抖音推广怎么收费
  • dnf卖飞机的网站怎么做的国家培训网官网
  • 淮北网站建设企业网站搜索优化网络推广
  • 炒币做合约哪个网站最好网站seo优化
  • 济南公司做网站的价格百度风云榜游戏
  • wordpress微信群发助手福建seo推广方案
  • 长沙专业做网站公司网上接单平台
  • 怎么样清除wordpress缓存班级优化大师的优点
  • 做美妆网站的关键词今天最新新闻报道
  • flash素材网站有哪些管理培训班
  • 常州网络推广哪家好seo在线论坛
  • 专业做网站路桥seo优化内容
  • 广告公司寮步网站建设网页推广平台
  • 网站建设调研报告的前言seo需要掌握哪些技术
  • 做一静态网站 多少钱南宁 百度网盘
  • 苏州网站建设套餐关键词优化的五个步骤
  • 网站代理怎么做搜索引擎优化的七个步骤
  • 网站建设的7个基本流程站长工具综合查询官网