GolangNote

Golang笔记

用flickr api go sdk 简单上传图片的例子

Permalink

flickr 提供1T 免费空间,用来存储图片不错,下面是go sdk 上传的例子

Go: 上传图片到 flickr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package main

import (
	"fmt"
	"github.com/mncaudill/go-flickr"
)

func main() {
	r := &flickr.Request{
		ApiKey: "xxxxx",
		Method: "flickr.photos.getInfo",
		Args: map[string]string{
			"photo_id": "5356343650",
		},
	}

	// 有些请求需要签名
	r.Sign("xxxxx")

	fmt.Println(r.URL())

	resp, err := r.Execute()
	if err != nil {
		fmt.Println(err)
	}
	fmt.Println(resp)

	// 上传
	rsp, err := r.Upload("thumb.jpg", "image/jpeg")
	if err != nil {
		fmt.Println(err)
	}
	fmt.Println(rsp)
}

本文网址: https://golangnote.com/topic/208.html 转摘请注明来源

Related articles

Write a Comment to "用flickr api go sdk 简单上传图片的例子"

Submit Comment Login
Based on Golang + fastHTTP + sdb | go1.22.3 Processed in 2ms