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'];
|
||||
}
|
||||
|
||||
if (values.noJSON) {
|
||||
extraHeaders['X-Zipline-NoJSON'] = 'true';
|
||||
} else {
|
||||
delete extraHeaders['X-Zipline-NoJSON'];
|
||||
}
|
||||
|
||||
for (const [key, value] of Object.entries(extraHeaders)) {
|
||||
curl.push('-H');
|
||||
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' : ''}
|
||||
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');
|
||||
|
|
|
@ -13,6 +13,7 @@ export function GeneratorModal({ opened, onClose, title, onSubmit, ...other }) {
|
|||
embed: false,
|
||||
wlCompatibility: false,
|
||||
wlCompositorNotSupported: false,
|
||||
noJSON: false,
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -37,7 +38,8 @@ export function GeneratorModal({ opened, onClose, title, onSubmit, ...other }) {
|
|||
/>
|
||||
|
||||
<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}
|
||||
min={0}
|
||||
mt='md'
|
||||
|
@ -45,18 +47,30 @@ export function GeneratorModal({ opened, onClose, title, onSubmit, ...other }) {
|
|||
{...form.getInputProps('imageCompression')}
|
||||
/>
|
||||
|
||||
<Group grow mt='md'>
|
||||
<Group grow my='md'>
|
||||
<Checkbox
|
||||
label='Zero Width Space'
|
||||
description='Use zero width spaces as the file name'
|
||||
id='zeroWidthSpace'
|
||||
{...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>
|
||||
|
||||
{title === 'Flameshot' && (
|
||||
<>
|
||||
<Box mt='md'>
|
||||
<Box my='md'>
|
||||
<Text>Wayland</Text>
|
||||
<MutedText size='sm'>
|
||||
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>
|
||||
</Box>
|
||||
|
||||
<Group mt='md'>
|
||||
<Group my='md'>
|
||||
<Checkbox
|
||||
label='Enable Wayland Compatibility'
|
||||
description={
|
||||
|
@ -99,12 +113,10 @@ export function GeneratorModal({ opened, onClose, title, onSubmit, ...other }) {
|
|||
</>
|
||||
)}
|
||||
|
||||
<Group grow>
|
||||
<Button mt='md' onClick={form.reset}>
|
||||
Reset
|
||||
</Button>
|
||||
<Group grow my='md'>
|
||||
<Button onClick={form.reset}>Reset</Button>
|
||||
|
||||
<Button mt='md' rightIcon={<DownloadIcon />} type='submit'>
|
||||
<Button rightIcon={<DownloadIcon />} type='submit'>
|
||||
Download
|
||||
</Button>
|
||||
</Group>
|
||||
|
|
|
@ -54,6 +54,15 @@ export default function ShareX({ user, open, setOpen }) {
|
|||
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');
|
||||
pseudoElement.setAttribute(
|
||||
'href',
|
||||
|
|
|
@ -268,6 +268,17 @@ async function handler(req: NextApiReq, res: NextApiRes) {
|
|||
fileName = file.originalname.split('.')[0];
|
||||
break;
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue