Skip to content

Commit 712cc35

Browse files
authored
Merge pull request #2726 from Permify/feature/unique-filename-generation
feat(main-layout): generate unique filename for YAML files on save
2 parents 84020c1 + 3820206 commit 712cc35

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

playground/src/layout/main-layout.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,13 @@ const MainLayout = ({children, ...rest}) => {
5959
attributes: attributes,
6060
scenarios: scenarios
6161
})
62-
const file = new File([yamlString], `s.yaml`, {type: 'text/x-yaml'});
63-
put("s.yaml", file, {
62+
// Generate unique filename to avoid conflicts
63+
const uniqueId = `${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
64+
const fileName = `${uniqueId}.yaml`;
65+
const file = new File([yamlString], fileName, {type: 'text/x-yaml'});
66+
put(fileName, file, {
6467
access: 'public',
65-
token: process.env.REACT_APP_BLOB_READ_WRITE_TOKEN,
66-
addRandomSuffix: true
68+
token: process.env.REACT_APP_BLOB_READ_WRITE_TOKEN
6769
}).then((result) => {
6870
let fileName = result.url.split('/').pop();
6971
setId(fileName.replace('.yaml', ''))

0 commit comments

Comments
 (0)