1.0.1 • Published 2 years ago

@hackmesenpai/gofile-api-wrapper v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

GoFile.io Unofficial API Wrapper

GoFile.io Logo

Unofficial API Wrapper for GoFile.io for easy API Calls that uses Axios and fs module.

INSTALL

npm i @hackmesenpai/gofile-api-wrapper

Functions Params (required and optional)

  • getServer() No Required Params
getServer()
  • getAccountDetails() Required Params usertoken
getAccountDetails([usertoken])
deleteContent([contentsId, usertoken])
//This feature is only for premium/subscribed users
copyContent([contentsId, usertoken, folderIdDestination])
createFolder([parentFolderID, usertoken, folderName])
//This feature is only for premium/subscribed users
getContent([contentsId, usertoken])
setFolderOptions([contentsId, usertoken, folderOptions, value])
//without usertoken and folderID
uploadFile([server, fileToUpload])

//with usertoken but no folderID creates automatically a folder with random name
uploadFile([server, fileToUpload, usertoken])

//Using Optional Params with folderID
uploadFile([server, fileToUpload, usertoken, folderID])

All Params

ParamsTypeExplanationSample
usertokenstringThe access token of an account you can get via loging in here. Can be retrieved from the profile page."PNxrcDBrUeAQNxdYLgWOafMtfxpXghM"
contentsIdstringIt can be a folderId or fileId, Comma separated contentId to delete (files or folders)"affdaa7c-134b-4397-a76f-e87970401d6d"
folderIdDestinationstringIts the destination folderId of any folder"affdaa7c-134b-4397-a76f-e87970401d6d"
folderNamestringyour folder name"Testing"
parentFolderIDstringIts the folderId of any folder"affdaa7c-134b-4397-a76f-e87970401d6d"
folderIdDestinationstringIts the folderId"affdaa7c-134b-4397-a76f-e87970401d6d"
fileToUploadstream or bufferthe file to be uploaded on the serverfs.createReadStream("testUpload.png")
folderIDstringIts the folderId"affdaa7c-134b-4397-a76f-e87970401d6d"
serverstringCan be Obtain via calling getServer()"store1"
folderIdDestinationstringIt the folderId"affdaa7c-134b-4397-a76f-e87970401d6d"
folderOptionsstringCan be "public", "password", "description", "expire" or "tags""public"
valuestringThe value of the option to be defined. For "public", can be "true" or "false". For "password", must be the password. For "description", must be the description. For "expire", must be the expiration date in the form of unix timestamp. For "tags", must be a comma seperated list of tags."true, yes or on" and "false, no or off"

FOR MORE INFO ABOUT API

Visit https://gofile.io/api

USAGES

Use require to Import

//for all functions to call
const { getAcountDetails, deleteContent, copyContent, createFolder, getContent, getServer, uploadFile, setFolderOptions } = require('@hackmesenpai/gofile-api-wrapper');

//but for example if you only want uploadFile
const { uploadFile } = require('@hackmesenpai/gofile-api-wrapper');

API Wrapper Functions

getServer()

Get the best server to recieve incoming files.

//Required to chain this using then() or define as a variable and using await to call when uploading file.
//Using then()
getServer().then((res)=>{
 console.log(res)
})

//Using Await
let res = await getServer()
console.log(res)

uploadFile()

Upload one file on a specific server.

//Required to use getServer() and chain this using then() or define as a variable and using await to call when uploading file.
//Using then()
let {data} = await getServer()
let server = data.server
let fileToUpload = fs.createReadStream("testUpload.png")

uploadFile(server, fileToUpload).then((res)=>{
 console.log(res)
})

//Using Await
let res = await uploadFile(server, fileToUpload)
console.log(res)

getAccountDetails()

Retrieving specific account information.

//Using then()
let usertoken = "PNxrcDBrUeAQNxdYLgWOafMtfxpXghM";

getAccountDetails(usertoken).then((res)=>{
 console.log(res)
})

//Using Await
let res = await getAccountDetails(usertoken)
console.log(res)

deleteContent()

Delete one or multiple files/folders.

//Using then()
let usertoken = "PNxrcDBrUeAQNxdYLgWOafMtfxpXghM";
let contentsId = "affdaa7c-134b-4397-a76f-e87970401d6d";

deleteContent(contentsId, usertoken).then((res)=>{
 console.log(res)
})

//Using Await
let res = await deleteContent(contentsId, usertoken)
console.log(res)

copyContent()

Available only for Premium/Subscribed Users. Copy one or multiple contents to another folder.

//Using then()
let usertoken = "PNxrcDBrUeAQNxdYLgWOafMtfxpXghM";
let contentsId = "affdaa7c-134b-4397-a76f-e87970401d6d";
let folderIdDestination = "Ifgaj4c-76h9-3680-x341-e50631705d6d";

copyContent(contentsId, usertoken, folderIdDestination).then((res)=>{
 console.log(res)
})

//Using Await
let res = await copyContent(contentsId, usertoken, folderIdDestination)
console.log(res)

createFolder()

Creates a new folder.

//Using then()
let usertoken = "PNxrcDBrUeAQNxdYLgWOafMtfxpXghM";
let parentFolderID = "affdaa7c-134b-4397-a76f-e87970401d6d";
let folderName = "My Folder";

createFolder(parentFolderID, usertoken, folderName).then((res)=>{
 console.log(res)
})

//Using Await
let res = await createFolder(parentFolderID, usertoken, folderName)
console.log(res)

getContent()

Available only for Premium/Subscribed Users. Get a specific content details.

//Using then()
let usertoken = "PNxrcDBrUeAQNxdYLgWOafMtfxpXghM";
let contentsId = "affdaa7c-134b-4397-a76f-e87970401d6d";

getContent(contentsId, usertoken).then((res)=>{
 console.log(res)
})

//Using Await
let res = await getContent(contentsId, usertoken)
console.log(res)

setFolderOptions()

Get a specific content details.

//Using then()
let usertoken = "PNxrcDBrUeAQNxdYLgWOafMtfxpXghM";
let contentsId = "affdaa7c-134b-4397-a76f-e87970401d6d";
let folderOptions = "public"; 
let value = "yes";

setFolderOptions(contentsId, usertoken, folderOptions, value).then((res)=>{
 console.log(res)
})

//Using Await
let res = await setFolderOptions(contentsId, usertoken, folderOptions, value)
console.log(res)
1.0.1

2 years ago

1.0.0

2 years ago