Unable to upload .png image in K6

Hello Grafana Community,

I hope this message finds you well. I’m reaching out for assistance regarding an issue I’ve been facing with K6 while trying to upload an image file.

I have the following setup:

  • K6 Version: k6 v0.52.0 (go1.22.4, darwin/arm64)
    I am trying to upload an image file as part of my K6 script. Here’s the relevant portion of my code:
    import { open } from ‘k6’;
    const imageFilePath = ‘/src/assest/captain.png’;
    try {
    const imageFile = open(imageFilePath, ‘b’);
    console.log(“Image file opened successfully:”, imageFile);
    } catch (error) {
    console.error(“Failed to open image file:”, error);
    }

Despite verifying the file path, file permissions, and ensuring the file exists, I keep receiving the following error when I run my script:
ERRO[0003] Failed to open image file at: /src/assest/captain.png {}

I checked the permissions and confirmed that I have read access to the file

Has anyone else encountered this issue with K6? Are there any additional troubleshooting steps I might be missing? Any insights or guidance would be greatly appreciated.

Hi @asmaaalnaanah.

I would recommedn not catching the error as that will give us slightly better message IMO.

On the other hand … are you sure it isn’t assets instad of assest in the path?