mirror of
https://github.com/BlueSkyXN/WorkerJS_CloudFlare_ImageBed.git
synced 2024-11-16 11:42:33 +08:00
0.9.18
This commit is contained in:
parent
81a1226b7f
commit
9f3a0c5676
|
@ -76,6 +76,8 @@
|
|||
<option value="qst8">qst8-国内CDN</option>
|
||||
<option value="vviptuangou">vviptuangou-国内CDN</option>
|
||||
<option value="da8m">da8m-国内CDN</option>
|
||||
<option value="10086">10086</option>
|
||||
<option value="tencent">TX</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-check mb-2">
|
||||
|
|
|
@ -51,7 +51,7 @@ async function handleimg2ipfsRequest(request) {
|
|||
|
||||
// 构建图片访问链接
|
||||
//const accessUrl = `https://cdn.img2ipfs.com/ipfs/${fileHash}?filename=${fileName}`;
|
||||
const accessUrl = `https://i0.wp.com/gateway.pinata.cloud/ipfs/${fileHash}`;
|
||||
const accessUrl = `https://i0.wp.com/eth.sucks/ipfs/${fileHash}`;
|
||||
console.log(`图片访问链接: ${accessUrl}`);
|
||||
|
||||
// 返回成功的链接
|
||||
|
|
|
@ -479,7 +479,7 @@ async function handleRequest(request) {
|
|||
|
||||
// 构建图片访问链接
|
||||
//const accessUrl = `https://cdn.img2ipfs.com/ipfs/${fileHash}?filename=${fileName}`;
|
||||
const accessUrl = `https://i0.wp.com/gateway.pinata.cloud/ipfs/${fileHash}`;
|
||||
const accessUrl = `https://i0.wp.com/eth.sucks/ipfs/${fileHash}`;
|
||||
console.log(`图片访问链接: ${accessUrl}`);
|
||||
|
||||
// 返回成功的链接
|
||||
|
@ -496,6 +496,7 @@ async function handleRequest(request) {
|
|||
return new Response('Internal Server Error', { status: 500 });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async function handleTgphimgRequest(request) {
|
||||
// 确认请求方法为 POST 并且内容类型正确
|
||||
|
@ -535,4 +536,135 @@ async function handleRequest(request) {
|
|||
return new Response('Error: ' + await response.text(), { status: response.status });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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 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 });
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user