fix: overrides for uploading
This commit is contained in:
parent
9bf098a93a
commit
873f77bc43
4 changed files with 56 additions and 11 deletions
|
@ -46,6 +46,12 @@ export default function Flameshot({ user, open, setOpen }) {
|
||||||
delete extraHeaders['Embed'];
|
delete extraHeaders['Embed'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (values.noJSON) {
|
||||||
|
extraHeaders['X-Zipline-NoJSON'] = 'true';
|
||||||
|
} else {
|
||||||
|
delete extraHeaders['X-Zipline-NoJSON'];
|
||||||
|
}
|
||||||
|
|
||||||
for (const [key, value] of Object.entries(extraHeaders)) {
|
for (const [key, value] of Object.entries(extraHeaders)) {
|
||||||
curl.push('-H');
|
curl.push('-H');
|
||||||
curl.push(`"${key}: ${value}"`);
|
curl.push(`"${key}: ${value}"`);
|
||||||
|
@ -53,7 +59,9 @@ export default function Flameshot({ user, open, setOpen }) {
|
||||||
|
|
||||||
const shell = `#!/bin/bash${values.wlCompositorNotSupported ? '\nexport XDG_CURRENT_DESKTOP=sway\n' : ''}
|
const shell = `#!/bin/bash${values.wlCompositorNotSupported ? '\nexport XDG_CURRENT_DESKTOP=sway\n' : ''}
|
||||||
flameshot gui -r > /tmp/ss.png;
|
flameshot gui -r > /tmp/ss.png;
|
||||||
${curl.join(' ')} | jq -r '.files[0]' | tr -d '\\n' | ${values.wlCompatibility ? 'wl-copy' : 'xsel -ib'};
|
${curl.join(' ')}${values.noJSON ? '' : " | jq -r '.files[0]'"} | tr -d '\\n' | ${
|
||||||
|
values.wlCompatibility ? 'wl-copy' : 'xsel -ib'
|
||||||
|
};
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const pseudoElement = document.createElement('a');
|
const pseudoElement = document.createElement('a');
|
||||||
|
|
|
@ -13,6 +13,7 @@ export function GeneratorModal({ opened, onClose, title, onSubmit, ...other }) {
|
||||||
embed: false,
|
embed: false,
|
||||||
wlCompatibility: false,
|
wlCompatibility: false,
|
||||||
wlCompositorNotSupported: false,
|
wlCompositorNotSupported: false,
|
||||||
|
noJSON: false,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -37,7 +38,8 @@ export function GeneratorModal({ opened, onClose, title, onSubmit, ...other }) {
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<NumberInput
|
<NumberInput
|
||||||
label={"Image Compression (leave at 0 if you don't want to compress)"}
|
label='Image Compression'
|
||||||
|
description='Set the image compression level (0-100). 0 is no compression, 100 is maximum compression.'
|
||||||
max={100}
|
max={100}
|
||||||
min={0}
|
min={0}
|
||||||
mt='md'
|
mt='md'
|
||||||
|
@ -45,18 +47,30 @@ export function GeneratorModal({ opened, onClose, title, onSubmit, ...other }) {
|
||||||
{...form.getInputProps('imageCompression')}
|
{...form.getInputProps('imageCompression')}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Group grow mt='md'>
|
<Group grow my='md'>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
label='Zero Width Space'
|
label='Zero Width Space'
|
||||||
|
description='Use zero width spaces as the file name'
|
||||||
id='zeroWidthSpace'
|
id='zeroWidthSpace'
|
||||||
{...form.getInputProps('zeroWidthSpace', { type: 'checkbox' })}
|
{...form.getInputProps('zeroWidthSpace', { type: 'checkbox' })}
|
||||||
/>
|
/>
|
||||||
<Checkbox label='Embed' id='embed' {...form.getInputProps('embed', { type: 'checkbox' })} />
|
<Checkbox
|
||||||
|
description='Image will display with embedded metadata'
|
||||||
|
label='Embed'
|
||||||
|
id='embed'
|
||||||
|
{...form.getInputProps('embed', { type: 'checkbox' })}
|
||||||
|
/>
|
||||||
|
<Checkbox
|
||||||
|
description='Return response as plain text instead of JSON'
|
||||||
|
label='No JSON'
|
||||||
|
id='noJSON'
|
||||||
|
{...form.getInputProps('noJSON', { type: 'checkbox' })}
|
||||||
|
/>
|
||||||
</Group>
|
</Group>
|
||||||
|
|
||||||
{title === 'Flameshot' && (
|
{title === 'Flameshot' && (
|
||||||
<>
|
<>
|
||||||
<Box mt='md'>
|
<Box my='md'>
|
||||||
<Text>Wayland</Text>
|
<Text>Wayland</Text>
|
||||||
<MutedText size='sm'>
|
<MutedText size='sm'>
|
||||||
If using wayland, you can check the boxes below to your liking. This will require{' '}
|
If using wayland, you can check the boxes below to your liking. This will require{' '}
|
||||||
|
@ -67,7 +81,7 @@ export function GeneratorModal({ opened, onClose, title, onSubmit, ...other }) {
|
||||||
</MutedText>
|
</MutedText>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
<Group mt='md'>
|
<Group my='md'>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
label='Enable Wayland Compatibility'
|
label='Enable Wayland Compatibility'
|
||||||
description={
|
description={
|
||||||
|
@ -99,12 +113,10 @@ export function GeneratorModal({ opened, onClose, title, onSubmit, ...other }) {
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<Group grow>
|
<Group grow my='md'>
|
||||||
<Button mt='md' onClick={form.reset}>
|
<Button onClick={form.reset}>Reset</Button>
|
||||||
Reset
|
|
||||||
</Button>
|
|
||||||
|
|
||||||
<Button mt='md' rightIcon={<DownloadIcon />} type='submit'>
|
<Button rightIcon={<DownloadIcon />} type='submit'>
|
||||||
Download
|
Download
|
||||||
</Button>
|
</Button>
|
||||||
</Group>
|
</Group>
|
||||||
|
|
|
@ -54,6 +54,15 @@ export default function ShareX({ user, open, setOpen }) {
|
||||||
setConfig(config);
|
setConfig(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (values.noJSON) {
|
||||||
|
config.URL = '{response}';
|
||||||
|
config.Headers['X-Zipline-NoJSON'] = 'true';
|
||||||
|
setConfig(config);
|
||||||
|
} else {
|
||||||
|
delete config.Headers['X-Zipline-NoJSON'];
|
||||||
|
setConfig(config);
|
||||||
|
}
|
||||||
|
|
||||||
const pseudoElement = document.createElement('a');
|
const pseudoElement = document.createElement('a');
|
||||||
pseudoElement.setAttribute(
|
pseudoElement.setAttribute(
|
||||||
'href',
|
'href',
|
||||||
|
|
|
@ -268,6 +268,17 @@ async function handler(req: NextApiReq, res: NextApiRes) {
|
||||||
fileName = file.originalname.split('.')[0];
|
fileName = file.originalname.split('.')[0];
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
if (req.headers['x-zipline-filename']) {
|
||||||
|
fileName = req.headers['x-zipline-filename'] as string;
|
||||||
|
const existing = await prisma.image.findFirst({
|
||||||
|
where: {
|
||||||
|
file: fileName,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (existing) return res.badRequest(`file[${i}]: filename already exists: '${fileName}'`);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
fileName = randomChars(zconfig.uploader.length);
|
fileName = randomChars(zconfig.uploader.length);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -363,6 +374,11 @@ async function handler(req: NextApiReq, res: NextApiRes) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (req.headers['x-zipline-nojson']) {
|
||||||
|
res.setHeader('Content-Type', 'text/plain');
|
||||||
|
return res.end(response.files.join(','));
|
||||||
|
}
|
||||||
|
|
||||||
return res.json(response);
|
return res.json(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue