WebDAV como JSON: API autoalojada de un solo archivo

WebDAV como JSON: API autoalojada en un único archivo PHP o Node.js para listar, subir, descargar y borrar archivos, con CORS, autenticación por API key y filtrado por extensiones.

14 sept 2025 • 3 min read • Q2BSTUDIO Team

Inteligencia-Artificial-

WebDAV como JSON: API autoalojada de un solo archivo es una solución minimalista que convierte un único archivo PHP o Node.js en una API JSON para operaciones de archivos como listar, subir, descargar y borrar. Es ideal cuando se necesita un endpoint ligero para frontends, scripts de automatización o zonas de carga temporales.

Características clave: soporte CORS para llamadas desde el navegador, autenticación opcional por API key vía Authorization Bearer, lista blanca de extensiones para seguridad básica, implementación de un solo archivo en PHP o Node, y endpoints sencillos para listar, descargar, subir y eliminar archivos.

Endpoints y métodos HTTP: GET / para listar archivos en JSON; GET /?filename=abc.txt para descargar; POST o PUT / para subir (multipart o PUT); POST o PUT /?filename=abc.txt para subir binario a un nombre concreto; DELETE /?filename=abc.txt para borrar.

Instalación rápida: para Node.js basta colocar index.mjs en el servidor y arrancar node index.mjs o usar mkcert para HTTPS en desarrollo. En PHP se descarga el archivo index.php y se puede ejecutar con el servidor integrado php -S 0.0.0.0:8000. El enfoque de un solo archivo facilita desplegar en segundos y probar con fetch desde el navegador.

Ejemplos de uso con curl: listar curl https://localhost:8000/; búsqueda parcial curl https://localhost:8000/?q=report; descargar curl -O https://localhost:8000/?filename=abc.txt; descargar como attachment curl -OJ https://localhost:8000/?download&filename=abc.txt; subir multipart curl -F file=@abc.txt https://localhost:8000/; subir binario por PUT curl -X PUT --data-binary @abc.txt https://localhost:8000/?filename=abc.txt; borrar curl -X DELETE https://localhost:8000/?filename=abc.txt.

Autenticación: si se define la variable api_key en el archivo, la API requerirá el encabezado Authorization: Bearer API_KEY. Esta autenticación simple evita usos no autorizados cuando se expone el servicio a redes menos confiables.

Lista blanca de extensiones: se recomienda restringir los tipos de archivo permitidos para minimizar riesgos. Ejemplos de extensiones comúnmente permitidas: txt jpg png webp heic gif pdf docx xlsx zip mp4 gz. Ajustar y endurecer la lista según el caso de uso.

Buenas prácticas: servir siempre sobre HTTPS, habilitar una API key en producción, limitar las extensiones permitidas, ajustar permisos en el directorio escribible y considerar límites de tasa y registro de auditoría si el uso crece.

Licencia: MIT. WebDAV como JSON es una alternativa de la menor complejidad posible para exponer almacenamiento básico con control y compatibilidad CORS y autenticación.

En Q2BSTUDIO ofrecemos servicios de desarrollo de software a medida y aplicaciones a medida que integran soluciones como esta cuando se requieren APIs ligeras y seguras. Nuestro equipo puede adaptar e integrar herramientas autoalojadas dentro de arquitecturas más amplias en la nube, incluyendo despliegues y mejores prácticas en plataformas AWS y Azure para garantizar disponibilidad, seguridad y escalabilidad. Conozca más sobre nuestras soluciones de desarrollo de aplicaciones y software a medida y sobre nuestros servicios cloud en Servicios cloud AWS y Azure.

Además de desarrollo, en Q2BSTUDIO somos especialistas en inteligencia artificial y ofrecemos servicios de ia para empresas, agentes IA y soluciones de inteligencia de negocio y power bi para transformar datos en decisiones accionables. También cubrimos ciberseguridad y pentesting para proteger tus sistemas y datos. Palabras clave que nos definen: aplicaciones a medida software a medida inteligencia artificial ciberseguridad servicios cloud aws azure servicios inteligencia de negocio ia para empresas agentes IA power bi.

Si buscas una API de archivos rápida, desplegable en minutos y con las garantías básicas de seguridad y compatibilidad, WebDAV como JSON es una solución práctica. Si quieres integrarla profesionalmente, optimizarla para producción o incorporarla en una arquitectura con monitorización, copias y control de accesos, en Q2BSTUDIO podemos ayudarte a diseñar e implantar la solución adecuada a tu proyecto.

A BREAK?

Play for a moment before you go

OUR SERVICES

How we can help you

Artificial intelligence

AI agents, chatbots, and intelligent assistants that automate tasks and serve your customers 24/7 to improve the efficiency of your business.

More info

Software Development

Web, mobile, and desktop applications, intranets, e-commerce, SaaS, and management platforms designed for your company's specific needs.

More info

Cloud services

Migration, infrastructure, managed hosting, high availability, and security on Microsoft Azure and Amazon Web Services to help your business scale without limits.

More info

Cybersecurity and pentesting

Security audits, penetration testing and protection of applications, data and infrastructure on-premise and cloud, with ethical hacking and regulatory compliance.

More info

Business Intelligence

Dashboards and data analysis with Power BI: we integrate your sources, design dashboards and KPIs and turn your data into decisions.

More info

Process automation

We automate repetitive tasks and connect your applications with n8n, Power Automate, Make, and RPA, eliminating manual work and increasing productivity.

More info

Training for Companies

We train your teams in technology with criteria: web development, databases, Git, best practices and security, automation with n8n, artificial intelligence for companies and creation of AI solutions with Azure AI Foundry.

More info

Code Auditing

We audit the code that you, your team or an AI create: we tell you what is good and what to improve, we secure it and make it ready for production, web or app.

More info

AI Image Generation

We create for you the images that your business needs with artificial intelligence: product, networks, advertising, illustration and avatars. You tell us what you want and we deliver it ready to use.

More info

AI Video Generation

We create videos with artificial intelligence for you: promotional, networking, virtual presenters, dubbing and animations. You tell us the idea and we will deliver it assembled and ready to publish.

More info

AI Conversational Avatars

We create conversational avatars with AI – digital humans with a face and voice – that serve your customers and teams with the knowledge of your company, on your website, interactive monitors, WhatsApp or Teams.

More info

Online Marketing and AI

Google Ads, Meta Ads, LinkedIn Ads and AI Engine Positioning (GEO/AEO): we attract customers and make your brand appear where they search for you, also on ChatGPT, Gemini and Perplexity.

More info

Do you have a project in mind?

Tell us your vision and we'll turn it into a software solution. Whatever the scope, we make your idea real.

Live Chat