i want to control the uuid generated , to not have some characters in it . im uploading to minio in dev using aws s3 plugin , but it appends a uuid which has certain special characters which is affecting the functionality of my application.
marius
April 27, 2023, 9:06am
2
Are you using Uppy? Are you using our Transloadit services? It does not seem like it, so I will move it to the correct category.
it is related to this issue
opened 06:03PM - 27 Aug 22 UTC
closed 04:18AM - 17 Mar 23 UTC
Feature
Triage
### Initial checklist
- [X] I understand this is a feature request and question… s should be posted in the [Community Forum](https://community.transloadit.com/)
- [X] I searched [issues](https://github.com/transloadit/uppy/issues?q=is%3Aissue) and couldn’t find anything (or linked relevant results below)
### Problem
Since issue #3869 , there is no way for standalone Companion to opt-in to using the older "unsafe" version of getKey that would just use the filename provided by uppy frontend.
The getKey used in standalone is the defaultGetKey, which is now appending a random uuid in front of the filename :
```
module.exports.defaultGetKey = (req, filename) => `${crypto.randomUUID()}-${filename}`
```
This new behavior in v4 means users of standalone Companion that need or require to be able to dictate the S3 object key from the uppy frontend, cannot do so anymore.
The only way to retain control over the naming of S3 objects in v4 is to discontinue using Companion standalone and setup their own server and provide their own custom getKey to Companion server.
### Solution
Would the maintainer be opposed that we introduce a new environment variable (e.g. `COMPANION_S3_GETKEY_UNSAFE_BEHAVIOR`) that when set to `true`, will use the previous behavior of not prefixing the filename with a random uuid?
I propose to implement this in `companion/src/standalone/helper.js` as:
```
/**
* Loads the config from environment variables
*
* @returns {object}
*/
const getConfigFromEnv = () => {
...
return {
...
s3: {
getKey: process.env.COMPANION_S3_GETKEY_UNSAFE_BEHAVIOR ? utils.unsafeGetKey : utils.defaultGetKey,
...
}
...
}
```
and add an alternate unsafe getKey which preserves previous behavior in `companion/src/server/helpers/utils.js` :
```
module.exports.unsafeGetKey = (req, filename) => `${filename}`
```
If this is an acceptable solution, I'll create a PR. Any alternate suggestions or alternate naming are welcome too. I'm just wanting to preserve the old s3 key behavior (no random prefix) while using Companion standalone.
### Alternatives
Discontinue using Companion standalone and setup a custom server and provide a custom `getKey` to Companion server.
Feels drastic / cumbersome to put in this much work to retain an old behavior that is heavily integrated into an existing workflow.
This new behavior in v4 means users of standalone Companion that need or require to be able to dictate the S3 object key from the uppy frontend, cannot do so anymore.
i wasnt sure which category does it belong to . i just want exclude to certain characters in the appended uuid.