{"id":13342882,"url":"https://github.com/avitalique/xk6-file","last_synced_at":"2025-03-12T02:32:45.659Z","repository":{"id":38816768,"uuid":"351921391","full_name":"avitalique/xk6-file","owner":"avitalique","description":"k6 extension for writing files","archived":false,"fork":false,"pushed_at":"2024-06-10T09:29:32.000Z","size":30,"stargazers_count":23,"open_issues_count":2,"forks_count":12,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-07-30T21:05:34.222Z","etag":null,"topics":["k6","k6-extension","xk6"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/avitalique.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-26T21:56:30.000Z","updated_at":"2024-07-25T20:30:01.000Z","dependencies_parsed_at":"2024-06-19T03:14:28.870Z","dependency_job_id":null,"html_url":"https://github.com/avitalique/xk6-file","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avitalique%2Fxk6-file","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avitalique%2Fxk6-file/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avitalique%2Fxk6-file/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avitalique%2Fxk6-file/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/avitalique","download_url":"https://codeload.github.com/avitalique/xk6-file/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221265583,"owners_count":16788059,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["k6","k6-extension","xk6"],"created_at":"2024-07-29T19:30:06.561Z","updated_at":"2024-10-24T02:30:39.172Z","avatar_url":"https://github.com/avitalique.png","language":"Go","funding_links":[],"categories":["Extensions"],"sub_categories":["Community"],"readme":"# xk6-file\n[k6](https://github.com/grafana/k6) extension for writing files, implemented using the\n[xk6](https://github.com/grafana/xk6) system.\n\n## Build\n```shell\nxk6 build v0.54.0 --with github.com/avitalique/xk6-file@latest\n```\n\n## Example\n```javascript\nimport http from 'k6/http';\nimport { check } from 'k6';\nimport file from 'k6/x/file';\n\nconst filepath = 'sample-output.txt';\nconst binaryFilepath = 'sample-image.jpg';\n\nexport default function () {\n    // Write/append string to file\n    file.writeString(filepath, 'New file. First line.\\n');\n    file.appendString(filepath, `Second line. VU: ${__VU}  -  ITER: ${__ITER}`);\n\n    // Remove rows from text file/clear file content/delete file\n    file.removeRowsBetweenValues(filepath, 2, 2);\n    file.clearFile(filepath);\n    file.deleteFile(filepath);\n\n    // Write binary file\n    let response = http.get(\"https://upload.wikimedia.org/wikipedia/commons/3/3f/JPEG_example_flower.jpg\", {\n        responseType: \"binary\",\n    });\n    check(response, { 'status was 200': response.status === 200 });\n    file.writeBytes(binaryFilepath, Array.from(new Uint8Array(response.body)));\n    \n    // Rename file\n    file.renameFile(binaryFilepath, 'renamed-image.jpg')\n}\n\n```\n\n## Run sample script\n```shell\n./k6 run examples/sample-script.js\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favitalique%2Fxk6-file","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Favitalique%2Fxk6-file","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favitalique%2Fxk6-file/lists"}