Compare commits
No commits in common. "237da995235d9b96105f9e7a4b0bfafd4857d4a5" and "84f117584c1bf854f086e02e32155cf756888a2d" have entirely different histories.
237da99523
...
84f117584c
@ -1,7 +1,7 @@
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
const { request, Agent } = require('undici');
|
const { request } = require('undici');
|
||||||
|
|
||||||
const BASE_URL = 'https://clouddrop.cc';
|
const BASE_URL = 'https://clouddrop.cc';
|
||||||
const API_BASE = `${BASE_URL}/api/cloud`;
|
const API_BASE = `${BASE_URL}/api/cloud`;
|
||||||
@ -15,16 +15,6 @@ const COMPLETE_TIMEOUT = 5 * 60_000;
|
|||||||
const SHARE_TIMEOUT = 30_000;
|
const SHARE_TIMEOUT = 30_000;
|
||||||
const SIMPLE_UPLOAD_TIMEOUT = 30 * 60_000;
|
const SIMPLE_UPLOAD_TIMEOUT = 30 * 60_000;
|
||||||
|
|
||||||
// Cap concurrent TCP connections to clouddrop.cc at 50 to stay well under
|
|
||||||
// the server's per-IP limit of 100 concurrent connections (cd_conn).
|
|
||||||
// Shared across all ClouddropUploader instances via module-level agent.
|
|
||||||
const clouddropAgent = new Agent({
|
|
||||||
connections: 50,
|
|
||||||
pipelining: 1,
|
|
||||||
keepAliveTimeout: 30_000,
|
|
||||||
keepAliveMaxTimeout: 60_000
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clouddrop.cc uploader — uses API Key (Bearer) authentication.
|
* Clouddrop.cc uploader — uses API Key (Bearer) authentication.
|
||||||
* Files > 16 MB use the chunked protocol, smaller files use simple upload.
|
* Files > 16 MB use the chunked protocol, smaller files use simple upload.
|
||||||
@ -125,7 +115,6 @@ class ClouddropUploader {
|
|||||||
|
|
||||||
const res = await request(`${API_BASE}/upload?mode=rename`, {
|
const res = await request(`${API_BASE}/upload?mode=rename`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
dispatcher: clouddropAgent,
|
|
||||||
body: generate(),
|
body: generate(),
|
||||||
signal,
|
signal,
|
||||||
headers: this._headers({
|
headers: this._headers({
|
||||||
@ -149,7 +138,6 @@ class ClouddropUploader {
|
|||||||
// 1. Init session
|
// 1. Init session
|
||||||
const initRes = await request(`${API_BASE}/upload/init`, {
|
const initRes = await request(`${API_BASE}/upload/init`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
dispatcher: clouddropAgent,
|
|
||||||
signal,
|
signal,
|
||||||
headers: this._headers({ 'Content-Type': 'application/json' }),
|
headers: this._headers({ 'Content-Type': 'application/json' }),
|
||||||
body: JSON.stringify({ filename: fileName, size: fileSize, parentId: null }),
|
body: JSON.stringify({ filename: fileName, size: fileSize, parentId: null }),
|
||||||
@ -179,7 +167,6 @@ class ClouddropUploader {
|
|||||||
|
|
||||||
const chunkRes = await request(`${API_BASE}/upload/${sessionId}/chunk/${i}`, {
|
const chunkRes = await request(`${API_BASE}/upload/${sessionId}/chunk/${i}`, {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
dispatcher: clouddropAgent,
|
|
||||||
signal,
|
signal,
|
||||||
body: buf,
|
body: buf,
|
||||||
headers: this._headers({
|
headers: this._headers({
|
||||||
@ -201,7 +188,6 @@ class ClouddropUploader {
|
|||||||
// 3. Complete session
|
// 3. Complete session
|
||||||
const completeRes = await request(`${API_BASE}/upload/${sessionId}/complete`, {
|
const completeRes = await request(`${API_BASE}/upload/${sessionId}/complete`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
dispatcher: clouddropAgent,
|
|
||||||
signal,
|
signal,
|
||||||
headers: this._headers({ 'Content-Type': 'application/json' }),
|
headers: this._headers({ 'Content-Type': 'application/json' }),
|
||||||
body: '{}',
|
body: '{}',
|
||||||
@ -220,7 +206,6 @@ class ClouddropUploader {
|
|||||||
async _createShareLink(fileId, signal) {
|
async _createShareLink(fileId, signal) {
|
||||||
const res = await request(`${API_BASE}/share-link`, {
|
const res = await request(`${API_BASE}/share-link`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
dispatcher: clouddropAgent,
|
|
||||||
signal,
|
signal,
|
||||||
headers: this._headers({ 'Content-Type': 'application/json' }),
|
headers: this._headers({ 'Content-Type': 'application/json' }),
|
||||||
body: JSON.stringify({ fileId, expiry: 'never' }),
|
body: JSON.stringify({ fileId, expiry: 'never' }),
|
||||||
@ -238,7 +223,6 @@ class ClouddropUploader {
|
|||||||
if (!this.apiKey) throw new Error('Clouddrop: API-Key fehlt');
|
if (!this.apiKey) throw new Error('Clouddrop: API-Key fehlt');
|
||||||
const res = await request(`${API_BASE}/files?limit=1`, {
|
const res = await request(`${API_BASE}/files?limit=1`, {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
dispatcher: clouddropAgent,
|
|
||||||
signal,
|
signal,
|
||||||
headers: this._headers(),
|
headers: this._headers(),
|
||||||
headersTimeout: 15_000,
|
headersTimeout: 15_000,
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "multi-hoster-uploader",
|
"name": "multi-hoster-uploader",
|
||||||
"version": "2.7.1",
|
"version": "2.7.0",
|
||||||
"description": "Upload files to doodstream, voe, vidmoly, byse simultaneously",
|
"description": "Upload files to doodstream, voe, vidmoly, byse simultaneously",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user