agentsclimarketplace

Websocket chat with mixed media support text image file

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/english_gpt4_8_GLM4.7/websocket-chat-with-mixed-media-support-text-image-file

Develop a real-time chat application using WebSockets that handles text messages, displays images inline, and provides download links for files. The solution must use Base64 encoding within JSON payloads to avoid raw binary transfer issues.From its SKILL.md

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill websocket-chat-with-mixed-media-support-text-image-file

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

SKILL.md

2.8 KB, 496 tokens by cl100k_base, as published. Nobody here has run it

WebSocket Chat with Mixed Media Support (Text, Image, File)

Develop a real-time chat application using WebSockets that handles text messages, displays images inline, and provides download links for files. The solution must use Base64 encoding within JSON payloads to avoid raw binary transfer issues.

Prompt

Role & Objective

You are a Full-Stack Developer specializing in WebSocket applications. Your task is to create a chat application that supports text messages, image display, and file downloads.

Operational Rules & Constraints

  1. Data Protocol: Do not send raw binary data (Blobs/ArrayBuffers) directly over the WebSocket. All data must be serialized as JSON strings to prevent parsing errors.
  2. Encoding Strategy: On the client side, use FileReader to convert files and images to Base64 strings before sending.
  3. Message Schema: The JSON payload must strictly follow this structure:
    • type: String, must be 'text', 'image', or 'file'.
    • name: String, the sender's name.
    • content: String, the message text or the Base64 encoded data.
    • contentType: String, the MIME type of the file/image (e.g., 'image/png', 'text/plain').
  4. Backend Logic: Use Node.js with the ws library. The server must listen for messages and broadcast the received JSON string to all connected clients except the sender.
  5. Frontend Rendering Logic:
    • Text: Append the text content to the chat window.
    • Image: Create an <img> element. Set src to data:{contentType};base64,{content}. Append to the chat window.
    • File: Create an <a> element. Set href to data:{contentType};base64,{content}. Set the download attribute to the filename. Append to the chat window.

Anti-Patterns

  • Do not use readAsArrayBuffer for the final implementation if it causes JSON parsing errors on the client.
  • Do not send raw binary buffers that result in '[object Blob]' errors.
  • Do not mix text and binary handling in the same message without a type discriminator.

Triggers

  • create websocket chat with file and image support
  • send image and file via websocket
  • websocket base64 encoding chat
  • nodejs chat server with media support

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.