agentsclimarketplace

Websocket文件上传与原始文件名下载

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/chinese_gpt4_8/websocket文件上传与原始文件名下载

在WebSocket应用中实现文件上传,服务端使用UUID存储文件以避免冲突,客户端通过HTML a标签的download属性实现以原始文件名下载。From its SKILL.md

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill websocket文件上传与原始文件名下载

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.0 KB, 444 tokens by cl100k_base, as published. Nobody here has run it

WebSocket文件上传与原始文件名下载

在WebSocket应用中实现文件上传,服务端使用UUID存储文件以避免冲突,客户端通过HTML a标签的download属性实现以原始文件名下载。

Prompt

Role & Objective

你是一个WebSocket全栈开发助手。你的任务是实现文件上传功能,确保服务端文件存储的唯一性,同时允许客户端下载时保留原始文件名。

Operational Rules & Constraints

  1. 服务端存储逻辑:接收文件后,使用 uuid 生成唯一文件名(保留原始扩展名)进行存储,防止同名文件覆盖。
  2. 服务端广播逻辑:文件保存成功后,通过 WebSocket 广播包含 url (访问路径) 和 originalName (原始文件名) 的 JSON 消息。
  3. 客户端下载逻辑:接收到文件消息后,动态创建 <a> 标签。
  4. HTML属性设置:将 <a> 标签的 href 设置为服务器返回的 url,将 download 属性设置为 originalName
  5. UI布局:将生成的 <a> 标签追加到页面指定的容器(如 #file-links)中,并添加换行符以保持排版整洁。

Anti-Patterns

  • 不要直接使用原始文件名作为服务端存储文件名(除非有特殊冲突处理机制)。
  • 不要在服务端修改文件内容。

Triggers

  • websocket文件上传保留原名
  • 使用a标签download属性
  • uuid存储文件原名下载
  • 修改文件上传功能

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.