added header overrides

pull/15/head releases/0.1.0
tycrek 4 years ago
parent 5f9af34ac6
commit 62a2a7822a
No known key found for this signature in database
GPG Key ID: 25D74F3943625263

@ -79,6 +79,15 @@ In your Cloudflare DNS dashboard, make sure your domain/subdomain is set to **DN
- Deletion URL: `$json:.delete$`
6. The file `sample_config.sxcu` can also be modified & imported to suit your needs
### Header overrides
If you need to override a specific part of the config to be different from the global config, you may do so via "`X`" HTTP headers:
| Header | Purpose |
| ------ | ------- |
| **`X-Ass-Domain`** | Override the domain returned for the clipboard |
| **`X-Ass-Access`** | Override the generator used for the resource URI ([see above](#access-types)) |
## Contributing
No strict contributing rules at this time. I appreciate any Issues or Pull Requests.

@ -78,17 +78,21 @@ function startup() {
// Prevent uploads from unauthorized clients
if (!verify(req, tokens)) return res.sendStatus(401);
log(`Uploaded: ${req.file.originalname} (${req.file.mimetype})`);
// Load overrides
let trueDomain = getTrueDomain(req.headers["x-ass-domain"]);
let generator = req.headers["x-ass-access"] || resourceIdType;
// Save the file information
let resourceId = generateId(resourceIdType, resourceIdSize, req.file.originalname);
let resourceId = generateId(generator, resourceIdSize, req.file.originalname);
data[resourceId.split('.')[0]] = req.file;
saveData(data);
log(`Uploaded: ${req.file.originalname} (${req.file.mimetype})`);
// Send the response
res.type('json').send({
resource: `${getTrueHttp()}${getTrueDomain()}/${resourceId}`,
delete: `${getTrueHttp()}${getTrueDomain()}/delete/${req.file.filename}`
resource: `${getTrueHttp()}${trueDomain}/${resourceId}`,
delete: `${getTrueHttp()}${trueDomain}/delete/${req.file.filename}`
});
});
@ -139,8 +143,9 @@ function startup() {
function getTrueHttp() {
return ('http').concat(useSsl ? 's' : '').concat('://');
}
function getTrueDomain() {
return domain.concat((port == 80 || port == 443 || isProxied) ? '' : `:${port}`);
function getTrueDomain(d = domain) {
return d.concat((port == 80 || port == 443 || isProxied) ? '' : `:${port}`);
}
function genHtml(resourceId) {

Loading…
Cancel
Save