golang远程图片本地化

go-image-local 是一个用go开发的将指定文本中的图片本地化的包。其可配置将图片本地化或者上传到对象存储(对象存储使用的是qwxingzhe/go-object-storage包),可轻易的集成到go项目中,欢迎使用。

安装

$ go get -u github.com/qwxingzhe/go-image-local

使用指南

配置本地存储引擎

localDrives := drives.FileDrives{
	BasePath: "./storage/",
}

配置对象存储引擎(七牛云kodo)

参数配置可参看 qwxingzhe/go-object-storage

localDrives := drives.KodoDrives{
	ObjectStorageDrive: &ObjectStorage.ObjectStorage{
		Drive: ObjectStorageDrives.Kodo{
			AccessKey: kodoConfig.AccessKey,
			SecretKey: kodoConfig.SecretKey,
			Bucket:    kodoConfig.Bucket,
		},
		IsAutomaticProductionPath: true,
		FilePathPrefix:            "test2/",
		IsAppendExt:               false,
		BaseUrl:                   "http://qynr9haq9.hd-bkt.clouddn.com/",
	},
}

调用

content := "<img src=\"https://img-home.csdnimg.cn/images/20210827090533.png\">XXX<img  src=\"https://img-blog.csdnimg.cn/606d5fec02674021be47ea0358417e46.jpg?x-oss-process=image/resize,m_fixed,h_200\">"
content = ImageToLocal(localDrives, content)
fmt.Println(content)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值