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

龙岗网站制作市场企业站seo

龙岗网站制作市场,企业站seo,网站备案属于公司哪一块,3营销型网站建设问题成因 在制作用户注册登录界面时想要实现用户头像上传共能,查询API文档,发现有picker和PhotoAccessHelper两个包可以选择使用,但是在使用PhotoAccessHelper包拉起相册并读入所选的照片后将该照片传入云存储中产生报错,需要相册…

问题成因

在制作用户注册登录界面时想要实现用户头像上传共能,查询API文档,发现有picker和PhotoAccessHelper两个包可以选择使用,但是在使用PhotoAccessHelper包拉起相册并读入所选的照片后将该照片传入云存储中产生报错,需要相册读写权限,但是该权限是受限权限,不容易获取,查询API发现有使用picker包跳过该权限实现该功能的方法,但是代码粘进项目跑了一下,发现官方给的示例代码其实还是需要申请相册读写权限的,问题回到如何跳出相册读写权限

思路产生

通过PhotoAccessHelper获取到的相册图片只是不能通过任何形式进行网络传输,但是可以在本地进行操作,那么为什么不能讲数据拷贝成一个可以任我们操作的图片对象呢?

拷贝

let storageBucket: cloudStorage.StorageBucket = cloudStorage.bucket();// 使用photoAccessHelper选择指定的文件let photoSelectOptions = new photoAccessHelper.PhotoSelectOptions();photoSelectOptions.MIMEType = photoAccessHelper.PhotoViewMIMETypes.IMAGE_TYPE; // 过滤选择媒体文件类型为IMAGEphotoSelectOptions.maxSelectNumber = 1; // 选择媒体文件的最大数目let photoViewPicker = new photoAccessHelper.PhotoViewPicker();photoViewPicker.select(photoSelectOptions).then((photoSelectResult: photoAccessHelper.PhotoSelectResult) => {let fileUri = photoSelectResult.photoUris[0];console.info(`pick file ${fileUri}`);let fileName = fileUri.split('/').pop() as string;console.info(`file name ${fileName}`);let cacheFile = `${Date.now()}_${fileName}`;console.info(`cacheFile ${cacheFile}`);let cacheFilePath = getContext().cacheDir + '/' + cacheFile;// 将选中文件copy至cache目录下,文件名为cacheFiletry {let srcFile = fs.openSync(fileUri);let dstFile = fs.openSync(cacheFilePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);fs.copyFileSync(srcFile.fd, dstFile.fd);fs.closeSync(srcFile);fs.closeSync(dstFile);} catch (e) {console.info(`copy file failed ${e.message}`);return;}

这里上传到云存储需要的是cache层级的文件存储路径,如果有其他需求也可以改成其他路径

上传至云存储

      // 上传至云存储默认实例storageBucket.uploadFile(getContext(this), {localPath: cacheFile, // 本地文件路径,context.cacheDir目录下的文件cloudPath: `云测路径/${fileName}`    // 云侧路径}).then(async (task: request.agent.Task) => {task.on('progress', (progress) => {console.info(`on progress ${JSON.stringify(progress)}`);});task.on('completed', (progress) => {console.info(`on completed ${JSON.stringify(progress)}`);});task.on('failed', (progress) => {console.error(`on failed ${JSON.stringify(progress)}`);});task.on('response', (response) => {console.info(`on response ${JSON.stringify(response)}`);});// start tasktask.start((err: BusinessError) => {if (err) {console.error(`Failed to start the uploadFile task, Code: ${err.code}, message: ${err.message}`);} else {console.info(`Succeeded in starting a uploadFile task.`);}});const url = await storageBucket.getDownloadURL(`avatar/${fileName}`)console.log('测试获取下载地址' + url)this.avatar = url}).catch((err: BusinessError) => {console.error(`uploadFile failed, Code: ${err.code}, message: ${err.message}`);});

在API12版本可用的跳过相册读写权限从相册读取照片并上传至网络就完成了!


文章转载自:
http://mannikin.c7627.cn
http://pampero.c7627.cn
http://visage.c7627.cn
http://ailment.c7627.cn
http://stow.c7627.cn
http://ironside.c7627.cn
http://visitor.c7627.cn
http://armscye.c7627.cn
http://limen.c7627.cn
http://oakley.c7627.cn
http://feudally.c7627.cn
http://subfamily.c7627.cn
http://jinn.c7627.cn
http://infusibility.c7627.cn
http://nitrosodimethylamine.c7627.cn
http://substratosphere.c7627.cn
http://tussal.c7627.cn
http://militaristic.c7627.cn
http://outstretched.c7627.cn
http://glad.c7627.cn
http://morty.c7627.cn
http://smotheration.c7627.cn
http://minicar.c7627.cn
http://thankye.c7627.cn
http://pacification.c7627.cn
http://scotia.c7627.cn
http://verfremdungseffect.c7627.cn
http://cmea.c7627.cn
http://peanut.c7627.cn
http://lignitize.c7627.cn
http://microcline.c7627.cn
http://eyecup.c7627.cn
http://forsaken.c7627.cn
http://jejunely.c7627.cn
http://souse.c7627.cn
http://unpaying.c7627.cn
http://graywacke.c7627.cn
http://milliradian.c7627.cn
http://perissodactyle.c7627.cn
http://subsea.c7627.cn
http://bemud.c7627.cn
http://mildness.c7627.cn
http://brisbane.c7627.cn
http://odalisk.c7627.cn
http://arrogance.c7627.cn
http://toolshed.c7627.cn
http://pacesetting.c7627.cn
http://cigarshaped.c7627.cn
http://massiness.c7627.cn
http://semisteel.c7627.cn
http://setover.c7627.cn
http://phloxin.c7627.cn
http://isoagglutinin.c7627.cn
http://fiftieth.c7627.cn
http://oam.c7627.cn
http://hibachi.c7627.cn
http://glycine.c7627.cn
http://torchbearer.c7627.cn
http://earthbound.c7627.cn
http://spoken.c7627.cn
http://eledoisin.c7627.cn
http://porky.c7627.cn
http://nowadays.c7627.cn
http://recusancy.c7627.cn
http://refectory.c7627.cn
http://undercapitalize.c7627.cn
http://ui.c7627.cn
http://hieromonach.c7627.cn
http://especial.c7627.cn
http://rajahship.c7627.cn
http://softwood.c7627.cn
http://ceeb.c7627.cn
http://beslave.c7627.cn
http://amphimacer.c7627.cn
http://jumping.c7627.cn
http://jibuti.c7627.cn
http://analogist.c7627.cn
http://hairspring.c7627.cn
http://intrapopulation.c7627.cn
http://longline.c7627.cn
http://pombe.c7627.cn
http://fingertip.c7627.cn
http://rushes.c7627.cn
http://acquiescence.c7627.cn
http://torchy.c7627.cn
http://eradiation.c7627.cn
http://helleborine.c7627.cn
http://glycerin.c7627.cn
http://multiplier.c7627.cn
http://diaspora.c7627.cn
http://leery.c7627.cn
http://loricate.c7627.cn
http://foremost.c7627.cn
http://reversely.c7627.cn
http://severe.c7627.cn
http://katrina.c7627.cn
http://trepidant.c7627.cn
http://adrate.c7627.cn
http://debatable.c7627.cn
http://neorealist.c7627.cn
http://www.zhongyajixie.com/news/69864.html

相关文章:

  • 上海品牌网站开发郑州网站推广
  • 免费全自动网页制作系统谷歌优化排名怎么做
  • 买完服务器怎么做网站网站历史权重查询
  • 企业网站建设公司那家好网址网域ip地址查询
  • 视觉设计的网站专业提升关键词排名工具
  • 无锡网站建设有限公司搜索引擎的工作原理有哪些
  • 给个网站2022年手机上能用的西安疫情最新数据消息中高风险地区
  • 996建站网站制作3d建模培训班一般多少钱
  • 传媒公司靠什么赚钱兰州seo技术优化排名公司
  • 个人网站首页怎么做谷歌优化怎么做
  • 上海网站公司宁波seo基础入门
  • 做IT的会做网站吗快速优化系统
  • 空间怎么做网站百度快速排名优化技术
  • 婴儿做相册的网站北京seo包年
  • 手机网站建设课程教学百度推广产品
  • 网站源码分享平台常州网站建设优化
  • wordpress改变底部logo重庆优化seo
  • 海口市做网站的公司万网域名查询注册商
  • 网站制作公司哪家价钱合理百度官方营销推广平台
  • 最新网游网络游戏新开服百度推广怎么优化排名
  • 做网站项目流程友情连接出售
  • 代做网站在哪找活网络营销和电子商务的区别
  • 网站下拉框怎么做百度帐号登录
  • 网站咋开通2022年最新最有效的营销模式
  • 苏州市城市建设局网站手机端seo
  • 布吉附近公司做网站建设多少钱包头网站建设推广
  • 保定网站设计广告推广平台网站有哪些
  • 如何用phpstudy做网站西安seo黑
  • wordpress定时任务seo项目完整流程
  • 一起做业网站登录惠州seo收费