Skip to content

Latest commit

 

History

History
88 lines (66 loc) · 1.59 KB

File metadata and controls

88 lines (66 loc) · 1.59 KB

gopenload

Golang client of the openload.co service.

Build Status Go Report Card GoDoc

Installation

$ go get github.com/mohan3d/gopenload

Usage

implemented API features.

Retrieve account info

package main

import (
	"fmt"

	"github.com/mohan3d/gopenload/openload"
)

func main() {
	// Create a client.
	client := openload.New("<LOGIN>", "<KEY>", nil)

	// Get account info.
	info, err := client.AccountInfo()

	if err != nil {
		panic(err)
	}
	fmt.Println(info.Email)
	fmt.Println(info.SignupAt)
}

Upload file

package main

import (
	"fmt"

	"github.com/mohan3d/gopenload/openload"
)

func main() {
	client := openload.New("<LOGIN>", "<KEY>", nil)
	uploaded, err := client.Upload("/path/dummyfile.txt", "", "", false)

	if err != nil {
		panic(err)
	}
	fmt.Println(uploaded.URL)
	fmt.Println(uploaded.ID)
	fmt.Println(uploaded.Size)
}

Retrieve file info

package main

import (
	"fmt"

	"github.com/mohan3d/gopenload/openload"
)

func main() {
	client := openload.New("<LOGIN>", "<KEY>", nil)
	info, err := client.FileInfo("uxbligkQAiN")

	if err != nil {
		panic(err)
	}
	fmt.Println(info.Name)
	fmt.Println(info.Size)
	fmt.Println(info.Status)
}