Giter VIP home page Giter VIP logo

bdyp_upload_golang's Introduction

bdyp_upload_golang

安装

go get github.com/zcxey2911/bdyp_upload_golang

获取code

访问obb网址:https://openapi.baidu.com/oauth/2.0/authorize?client_id=你的应用key&response_type=code&redirect_uri=oob&scope=basic+netdisk

调用上传

package main

import (
	"fmt"
	bdyp "github.com/zcxey2911/bdyp_upload_golang"
	"os"
)

func main() {

	var bcloud = bdyp.Bcloud{}

	// 获取token
	res, err := bcloud.GetToken("obb获取的code", "oob", "应用appkey", "应用appsecret")

	fmt.Println(res)

	if err != nil {
		fmt.Println("err", err)
	} else {
		fmt.Printf("接口的token是: %#v\n", res.AccessToken)
	}
	// 读取文件
	f, err := os.Open("/Users/liuyue/Downloads/ju1.webp")
	if err != nil {
		fmt.Println("err", err)
		return
	}
	defer f.Close()

	// 上传文件
	print(bcloud.Upload(&bdyp.FileUploadReq{
		Name:  "/apps/云盘备份/ju2.webp",
		File:  f,
		RType: nil,
	}))

}

bdyp_upload_golang's People

Stargazers

 avatar  avatar Wang Chao avatar  avatar  avatar lukou3 avatar Xyfacai avatar Kazusa avatar  avatar Roman avatar kuba avatar  avatar DY avatar woshizilong avatar Sayan Maity avatar 刘悦 avatar

Watchers

刘悦 avatar

Forkers

woshizilong

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.