@hackmesenpai/gofile-api-wrapper
v1.0.1
Published
Unofficial API Wrapper for GoFile.io for easy API Calls that uses Axios and fs module.
Downloads
12
Readme
GoFile.io Unofficial API Wrapper
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()
Required Params [contentsId, usertoken]deleteContent([contentsId, usertoken])
deleteContent([contentsId, usertoken])
copyContent()
Required Params [contentsId, usertoken, folderIdDestination]
//This feature is only for premium/subscribed users
copyContent([contentsId, usertoken, folderIdDestination])
createFolder()
Required Params [parentFolderID, usertoken, folderName]
createFolder([parentFolderID, usertoken, folderName])
getContent()
Required Params [contentsId, usertoken]
//This feature is only for premium/subscribed users
getContent([contentsId, usertoken])
setFolderOptions()
Required Params [contentsId, usertoken, folderOptions, value]
setFolderOptions([contentsId, usertoken, folderOptions, value])
uploadFile()
Required Params [server, fileToUpload] Optional Params [usertoken, folderID]
//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
Params | Type | Explanation | Sample
--- | --- | --- | ---
usertoken
| string | The access token of an account you can get via loging in here. Can be retrieved from the profile page. | "PNxrcDBrUeAQNxdYLgWOafMtfxpXghM"
contentsId
| string | It can be a folderId or fileId, Comma separated contentId to delete (files or folders) | "affdaa7c-134b-4397-a76f-e87970401d6d"
folderIdDestination
| string | Its the destination folderId of any folder | "affdaa7c-134b-4397-a76f-e87970401d6d"
folderName
| string | your folder name | "Testing"
parentFolderID
| string | Its the folderId of any folder | "affdaa7c-134b-4397-a76f-e87970401d6d"
folderIdDestination
| string | Its the folderId | "affdaa7c-134b-4397-a76f-e87970401d6d"
fileToUpload
| stream or buffer | the file to be uploaded on the server | fs.createReadStream("testUpload.png")
folderID
| string | Its the folderId | "affdaa7c-134b-4397-a76f-e87970401d6d"
server
| string | Can be Obtain via calling getServer()
| "store1"
folderIdDestination
| string | It the folderId | "affdaa7c-134b-4397-a76f-e87970401d6d"
folderOptions
| string | Can be "public", "password", "description", "expire" or "tags" | "public"
value
| string | The 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)