mirror of
https://github.com/BlueSkyXN/WorkerJS_CloudFlare_ImageBed.git
synced 2024-11-16 03:32:26 +08:00
0.9.14
移除不可用图床,调整了默认前端排序和说明
This commit is contained in:
parent
e94fcdac65
commit
7142d61408
|
@ -70,16 +70,13 @@
|
|||
<div class="form-group">
|
||||
<label for="apiSelect">Select Endpoint</label>
|
||||
<select class="form-control" id="apiSelect">
|
||||
<option value="10086">10086</option>
|
||||
<option value="tgphimg">tgph-official</option>
|
||||
<option value="ipfs">IPFS</option>
|
||||
<option value="58img">58img</option>
|
||||
<option value="tencent">Tencent</option>
|
||||
<option value="qst8">qst8</option>
|
||||
<option value="vviptuangou">vviptuangou</option>
|
||||
<option value="da8m">da8m</option>
|
||||
<option value="aagmoe">ihs.aag.moe</option>
|
||||
<option value="s3filebase">s3filebase</option>
|
||||
<option value="tencent">Tencent-国内外分流</option>
|
||||
<option value="58img">58img-定期删图</option>
|
||||
<option value="ipfs">IPFS-去中心化多网关兼容</option>
|
||||
<option value="tgphimg">TGPH-Debug通道</option>
|
||||
<option value="qst8">qst8-国内CDN</option>
|
||||
<option value="vviptuangou">vviptuangou-国内CDN</option>
|
||||
<option value="da8m">da8m-国内CDN</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-check mb-2">
|
||||
|
|
|
@ -157,130 +157,6 @@ async function handleRequest(request) {
|
|||
return btoa(binary);
|
||||
}
|
||||
|
||||
async function handleaagmoeRequest(request) {
|
||||
try {
|
||||
// 确认请求方法为 POST 并且内容类型正确
|
||||
if (request.method !== 'POST' || !request.headers.get('Content-Type').includes('multipart/form-data')) {
|
||||
return new Response('Invalid request', { status: 400 });
|
||||
}
|
||||
|
||||
// 解析表单数据
|
||||
const formData = await request.formData();
|
||||
const imageFile = formData.get('image'); // 假设字段名为 'image'
|
||||
if (!imageFile) return new Response('Image file not found', { status: 400 });
|
||||
|
||||
// 创建新的 FormData 对象,并将 'image' 字段重命名为 'file'
|
||||
const newFormData = new FormData();
|
||||
newFormData.append('file', imageFile); // 使用目标接口的字段名 'file'
|
||||
|
||||
// ihs.aag.moe 的上传接口
|
||||
const targetUrl = 'https://ihs.aag.moe/upload.php';
|
||||
|
||||
// 为了与 ihs.aag.moe 接口兼容,我们保留表单数据的格式并直接转发
|
||||
const response = await fetch(targetUrl, {
|
||||
method: 'POST',
|
||||
body: newFormData, // 使用新的 FormData 对象
|
||||
headers: {
|
||||
'Accept': '*/*',
|
||||
'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8,zh-TW;q=0.7',
|
||||
'Cache-Control': 'no-cache',
|
||||
'Origin': 'https://ihs.aag.moe',
|
||||
'Pragma': 'no-cache',
|
||||
'Referer': 'https://ihs.aag.moe/',
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36',
|
||||
'Sec-CH-UA': '"Chromium";v="124", "Google Chrome";v="124", "Not-A.Brand";v="99"',
|
||||
'Sec-CH-UA-Mobile': '?0',
|
||||
'Sec-CH-UA-Platform': '"Windows"',
|
||||
'Sec-Fetch-Dest': 'empty',
|
||||
'Sec-Fetch-Mode': 'cors',
|
||||
'Sec-Fetch-Site': 'same-origin',
|
||||
'DNT': '1'
|
||||
}
|
||||
});
|
||||
|
||||
// 处理响应
|
||||
if (response.ok) {
|
||||
const result = await response.json();
|
||||
if (result && result.success && result.file_url) {
|
||||
return new Response(result.file_url, { status: 200 });
|
||||
} else {
|
||||
return new Response('Error: Unexpected response format or upload failed', { status: 500 });
|
||||
}
|
||||
} else {
|
||||
return new Response('Error: ' + await response.text(), { status: response.status });
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Caught an error:', error);
|
||||
return new Response('Server Error', { status: 500 });
|
||||
}
|
||||
}
|
||||
|
||||
async function handle10086Request(request) {
|
||||
console.log('Request received:', request.url);
|
||||
|
||||
if (request.method !== 'POST') {
|
||||
return new Response('Method not allowed', { status: 405 });
|
||||
}
|
||||
|
||||
try {
|
||||
const formData = await request.formData();
|
||||
const file = formData.get('image'); // 使用 'image' 字段名
|
||||
if (!file) {
|
||||
return new Response('No file uploaded', { status: 400 });
|
||||
}
|
||||
|
||||
const newFormData = new FormData();
|
||||
newFormData.append('file', file, file.name); // 上传到目标服务器时使用 'file'
|
||||
|
||||
const targetUrl = 'https://mlw10086.serv00.net/upload.php';
|
||||
|
||||
const response = await fetch(targetUrl, {
|
||||
method: 'POST',
|
||||
body: newFormData,
|
||||
headers: {
|
||||
'Accept': '*/*',
|
||||
'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8,zh-TW;q=0.7',
|
||||
'Cache-Control': 'no-cache',
|
||||
'DNT': '1',
|
||||
'Origin': 'https://mlw10086.serv00.net',
|
||||
'Pragma': 'no-cache',
|
||||
'Referer': 'https://mlw10086.serv00.net/',
|
||||
'Sec-Ch-Ua': '"Chromium";v="128", "Not;A=Brand";v="24", "Google Chrome";v="128"',
|
||||
'Sec-Ch-Ua-Mobile': '?0',
|
||||
'Sec-Ch-Ua-Platform': '"Windows"',
|
||||
'Sec-Fetch-Dest': 'empty',
|
||||
'Sec-Fetch-Mode': 'cors',
|
||||
'Sec-Fetch-Site': 'same-origin',
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36'
|
||||
}
|
||||
});
|
||||
|
||||
console.log('Response status:', response.status);
|
||||
const responseText = await response.text();
|
||||
console.log('Response body:', responseText);
|
||||
|
||||
try {
|
||||
const jsonResponse = JSON.parse(responseText);
|
||||
if (jsonResponse.code === 200 && jsonResponse.url) {
|
||||
return new Response(jsonResponse.url, {
|
||||
status: 200,
|
||||
headers: { 'Content-Type': 'text/plain' }
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Failed to parse JSON:', e);
|
||||
}
|
||||
|
||||
return new Response(responseText, {
|
||||
status: response.status,
|
||||
headers: response.headers
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Error:', error);
|
||||
return new Response('Internal Server Error', { status: 500 });
|
||||
}
|
||||
}
|
||||
|
||||
async function handleTencentRequest(request) {
|
||||
try {
|
||||
// 确保请求方法为 POST
|
||||
|
|
Loading…
Reference in New Issue
Block a user