2024-10-28 09:26:33 +00:00
|
|
|
import { uuidv4 } from './k6-utils-1.4.0.js';
|
2024-10-23 14:14:54 +00:00
|
|
|
|
|
|
|
export function generateS3Key() {
|
2024-10-28 09:26:33 +00:00
|
|
|
let width = parseInt(__ENV.DIR_WIDTH || '0');
|
|
|
|
let height = parseInt(__ENV.DIR_HEIGHT || '0');
|
|
|
|
|
|
|
|
let key = ''
|
|
|
|
if (width > 0 && height > 0) {
|
|
|
|
for (let index = 0; index < height; index++) {
|
|
|
|
const w = Math.floor(Math.random() * width) + 1;
|
|
|
|
key = key + 'dir' + w + '/';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
key += objName();
|
|
|
|
return key;
|
|
|
|
}
|
|
|
|
|
|
|
|
const asciiLetters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
|
|
|
|
|
|
|
|
function objName() {
|
|
|
|
if (__ENV.OBJ_NAME) {
|
|
|
|
return __ENV.OBJ_NAME;
|
|
|
|
}
|
|
|
|
const length = parseInt(__ENV.OBJ_NAME_LENGTH || '0');
|
|
|
|
if (length > 0) {
|
|
|
|
let name = "";
|
|
|
|
for (let i = 0; i < length; i++) {
|
|
|
|
name += asciiLetters.charAt(Math.floor(Math.random() * asciiLetters.length));
|
2024-10-23 14:14:54 +00:00
|
|
|
}
|
2024-10-28 09:26:33 +00:00
|
|
|
return name;
|
|
|
|
}
|
|
|
|
return uuidv4();
|
2024-10-23 14:14:54 +00:00
|
|
|
}
|