Skip to main content

Upload and extract function

Allows you to send a file to a file host, extract the download link and, if required, manage the manual deletion of the file.

🧠 Function overview​

function upload_to_host(request_data, response_format, link_extraction = [], affix = [], manage_file = []) {
// ...
}

πŸ“¦ Parameters explained​

πŸ“ request_data​

The base configuration for the HTTP request to the host:

  • request_data[0] β†’ Endpoint URL
  • request_data[1] β†’ HTTP method ("POST", "GET"…)
  • request_data[2] β†’ Body of the request (e.g. a FormData object)
  • request_data[3] β†’ Optional headers (e.g. { "Content-Type": "application/json" })

πŸ“¬ response_format​

Type of response expected from the server:

  • "json" β†’ if the server returns a JSON object
  • "text" β†’ if the server returns plain text or HTML

Rules to extract the download link from the server’s response:

  • πŸ”Ή Static: ["https://example.com/" + code] β€” build the link manually
  • πŸ”Ή Regex match: ["match", /regex/, index] β€” extract using a rege
  • πŸ”Ή Replace: ["replace", "&", "_"] β€” replace characters in a string
  • πŸ”Ή JSON path: ["data", "downloadPage"] β†’ will return data["data"]["downloadPage"]

🧩 affix​

Used to wrap the final link with a prefix and/or suffix:

  • affix[0] β†’ prefix (e.g. "https://host.com/file/")
  • affix[1] β†’ suffix (e.g. ".html")

πŸ—‘οΈ manage_file​

Used for hosts that allow deleting the uploaded file:

  • manage_file[0] β†’ Delete URL (string, regex, or nested JSON path)
  • manage_file[1] β†’ HTTP method ("DELETE", "POST"...)
  • manage_file[2] β†’ Delete body content
  • manage_file[3] β†’ [prefix, suffix] for delete URL

🧨 Special Case: Killcode System​

Some hosts (like those using XFileSharing Pro) require an extra step with a killcode before deletion. This is handled automatically:

if (manage_file[2][key][0] === "killcode") {
// Logic to extract the file ID
// Fetch the killcode page
// Extract killcode and optional token, code or/and rand
}

This allows deletion for hosts that use:

  • Separate token-based deletion pages
  • CSRF-protected forms
  • Dynamic or time-based kill links

πŸ§ͺ Examples​

upload_to_host(
[
"https://example.com/upload",
"POST",
formData,
{ Authorization: "Bearer token" }
],
"json",
["data", "url"]
);

βœ… Example 2: Text + Regex match​

upload_to_host(
[
"https://example.com/upload",
"POST",
formData
],
"text",
["match", /https:\/\/example\.com\/file\/[a-z0-9]+/, 0]
);

βœ… Example 3: Real case (Gofile)​

const sent_data_form = new FormData();
sent_data_form.append("file", STATE.file_to_upload);

const headers = api_key_host ? { "Authorization": "Bearer " + api_key_host } : {};

upload_to_host(
[
URL_FOR_BYPASS_CORS + "https://upload.gofile.io/uploadfile",
"POST",
sent_data_form,
headers
],
"json",
["data", "downloadPage"],
[],
api_key_host
? [
"https://api.gofile.io/contents",
"DELETE",
{
"contentsId": ["data", "parentFolder"]
},
[],
headers
]
: [
"https://api.gofile.io/contents",
"DELETE",
{
"contentsId":["data", "parentFolder"], "token": ["data", "guestToken"]
}
]
);