gofilego

package module
v0.0.0-...-f2aeef5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 28, 2020 License: MIT Imports: 12 Imported by: 2

README

Go Report Card

Gofilego!

Gofilego is a simple Golang wrapper around Gofile.io's API. It provides a basic library for uploading files inside your code and an executable to quickly upload files to Gofile.

Usage

To install the executable run:

go get -u github.com/0xSteeW/gofilego
go install github.com/0xSteeW/gofilego/gofilego-upload

To run it:

gofilego-upload -f test.file

Make sure you've set your GOPATH properly.

To get a basic help menu:

gofilego-upload -h
Library

To just install the library:

go get -u github.com/0xSteeW/gofilego

Then, import it in your code as follows:

import "github.com/0xSteeW/gofilego"

Documentation

Here is a basic example for uploading a file with email and password:

package main

import (
	"fmt"
	"github.com/0xSteeW/gofilego"
	"os"
)

func main() {
	conn, err := gofilego.NewConnection()
	if err != nil {
		fmt.Println(err.Error())
		return
	}
	uploadStruct := &gofilego.Connection{Email: "example@email.com", Password: "rockyou"}
	conn.Construct(uploadStruct)
	// Open a file for uploading
	reader, _ := os.Open("test.file")
	conn.AddFile("testfilename", reader)
	response, err := conn.Upload()
	if err != nil {
		fmt.Println(err.Error())
		return
	}
	fmt.Println(response.Data["code"])
	
}

Index

*Connection* - Struct
	Server	string
	FilesUploaded map[string]io.Reader
	Email	string
	Description	string
	Password	string
	Expire	time.Time
	Tags	[]string

*UploadResponse* - Struct 
	Status	string
	Data map[string]interface{}

func (conn *Connection):
	GetNewServer() error
	NewConnection() (*Connection, error)
	Construct(providedStruct *Connection)
	Upload() (*UploadResponse, error)
	AddFile(fileName string, reader io.Reader)
	AddEmail(email string)	
	AddDescription(desc string)
	AddPassword(pass string)
	AddExpire(tstamp time.Time)
	AddTags(tags ...string)

Documentation

Index

Constants

View Source
const VERSION = "v0.2"

VERSION represents the version of the library

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

type Connection struct {
	// Upload server name
	Server string
	// Map of files, represented by [filename]io.Reader
	FilesUploaded map[string]io.Reader
	// Upload email
	Email string
	// Upload description
	Description string
	// Upload Password
	Password string
	// Upload tags provided as string array
	Tags []string
	// Expiration date timestamp
	Expire int64
}

Connection represents a basic Gofile upload struct

func NewConnection

func NewConnection() (*Connection, error)

NewConnection creates a new default connection. Returns a basic connection struct.

func (*Connection) AddFile

func (conn *Connection) AddFile(name string, file io.Reader)

AddFile adds a file to the current connection struct

func (*Connection) Construct

func (conn *Connection) Construct(providedStruct *Connection)

Construct acts as a constructor. Requires a Connection struct.

func (*Connection) GetNewServer

func (conn *Connection) GetNewServer() error

GetNewServer refreshes best server via contacting gofile api

func (*Connection) SetDescription

func (conn *Connection) SetDescription(desc string)

SetDescription sets upload description

func (*Connection) SetEmail

func (conn *Connection) SetEmail(email string)

SetEmail sets upload email

func (*Connection) SetExpire

func (conn *Connection) SetExpire(timeStamp time.Time)

SetExpire sets expiration timestamp as a time.Time object

func (*Connection) SetPassword

func (conn *Connection) SetPassword(pass string)

SetPassword sets upload password

func (*Connection) SetTags

func (conn *Connection) SetTags(tags ...string)

SetTags receives tags as variadic arguments.

func (*Connection) Upload

func (conn *Connection) Upload() (*UploadResponse, error)

Upload files to gofile, using the Connection struct parameters

type UploadResponse

type UploadResponse struct {
	Status string
	Data   map[string]interface{}
}

UploadResponse is a struct representing the json response of the Gofile server

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL