jshare-react-native icon indicating copy to clipboard operation
jshare-react-native copied to clipboard

分享本地图片imagePath路径问题

Open Code4GL opened this issue 8 years ago • 5 comments

已经用过的方法: 1、看过@huangxiaohao 提出的路径问题处理,使用了其中讨论的方法; 其中运用react-native-fs中的RNFS.MainBundlePath方法获取路径,在安卓上面无法使用。(能获取到其他路径比如RNFS.PicturesDirectoryPath) 2、参照example中的路径,自己拼接的也不能成功;(强烈建议能否修改下example中路径引用) 3、在分享种类是text的时候,分享是成功的; 4、使用相对路径引用也是不成功的; 5、弹出的错误都是:“文件不存在”,code:“41027”; 6、分享网络图片imageUrl,微信不显示图片,QQ图片能显示。 疑惑点: 1、imagePath寻找的是哪里的路径? 2、不知道@huangxiaohao最后是怎么解决安卓上面的问题的? 环境: "janalytics-react-native": "^1.1.2", "jcore-react-native": "^1.2.5", "jpush-react-native": "^2.1.13", "jshare-react-native": "^1.3.1", "metro-bundler": "^0.22.1", "react": "16.2.0", "react-native": "0.52.2", "react-native-fs": "^2.9.12", "react-native-gesture-password": "^0.3.2", "react-native-update": "^5.0.0", "react-navigation": "^1.0.0-beta.27", "react-redux": "^5.0.6", "redux": "^3.7.2", "redux-thunk": "^2.2.0"

Code4GL avatar Apr 24 '18 08:04 Code4GL

没有你所谓方法的链接,不大明白你说的处理方法哈,说几点我能想到的,希望对你有所帮助:

  1. RNFS 除了MainBundlePath,还有 RNFS.ExternalDirectoryPath(Android) || RNFS.DocumentDirectoryPath (Android | iOS)
  2. Android 拼接路径,在前面加上 file:// 试试

Riant avatar May 04 '18 03:05 Riant

微信分享没有缩略图 好像是有大小限制的 好像是 32kb左右 如果用的七牛云服务 可以在 url后面拼接 ?imageView2/1/w/100/h/100/interlace/0/q/85

ghost avatar May 09 '18 06:05 ghost

@jielongz 感谢回复,这个大小我试过了。后来又找了找估计和微信那边的政策有关,估计微信那边更新了,jshare还没有更新。

Code4GL avatar May 09 '18 06:05 Code4GL

@Riant 在你们分享的源码里写写到: { type: 'link' platform: platformString // 分享到指定平台 url: String // 必填,网页 url imagePath: String // 选填,本地图片路径 imagePath,imageUrl 必须二选一 imageUrl: String // 选填,网络图片地址 imagePath imageUrl 必须二选一 (iOS 不支持) title: String // 选填 text: String // 选填 quote: String // 选填,分享引用 } 其中imageUrl属性iOS 不支持,但是我在使用过程中,ios不但支持imageUrl,而且完美支持;反而在android使用的时候分享到微信不显示小图片,这使我感到震惊。imagePath目前没有使用成功过!

Code4GL avatar May 15 '18 10:05 Code4GL

@Code4GL 我也是用的 imageUrl, 没测过 imagePath , BTW, 我也只是使用者,暂时还没有参与维护咯。

Riant avatar May 19 '18 01:05 Riant