Skip to content

[Bug]: cant get content of upload file #2878

Open
@daniera3

Description

@daniera3

Version

latest

Steps to reproduce

Image

cant get content of file uploaded

Expected behavior

get asdasdasd in post_data

Actual behavior

in pyptteer i can get this content with

    await cdp.send("Network.enable", {
        # Buffer up to 10 MB of POST/PUT data
        "maxPostDataSize": 0
    })
    async def on_request_will_be_sent(params):
        try:
            req = params["request"]
            if req.get("method") == "PUT" and "/api/file/raw" in req.get("url", ""):
                request_id = params["requestId"]
                # Ask Chrome: “Please give me the POST/PUT payload that you buffered.”
                resp = await cdp.send(
                    "Network.getRequestPostData",
                    {"requestId": request_id}
                )
                body = resp.get("postData", None)
                print("→ Caught PUT to /api/file/raw via Network:")
                print("   • request.postData →", body)
                # If you want bytes instead of a string, do:
                # raw_bytes = body.encode("utf-8")
                # print("   • as bytes:", raw_bytes)
        except Exception as e:
            # If "No post data available" still shows up, check that `maxPostDataSize` was set early enough.
            print("ERROR in on_request_will_be_sent:", e)

    cdp.on("Network.requestWillBeSent", lambda event: asyncio.create_task(on_request_will_be_sent(event)))

Additional context

No response

Environment

- Operating System: [Ubuntu 22.04]
- CPU: [arm64]
- Browser: [All, Chromium, Firefox, WebKit]
- Python Version: [3.12]
- Other info:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions