FeaturesTemplatesShowcaseTownie
AI
BlogDocsPricing
Log inSign up
dcm31
dcm31Imagetourl
Public
Like
Imagetourl
Home
Code
2
README.md
H
image-host.ts
Branches
1
Pull requests
Remixes
History
Environment variables
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
Code
/
Search
image-host.ts
https://dcm31--44435b2832a811f08f06569c3dd06744.web.val.run
README.md

Image Self-Hosting Service

This is a web application and API that allows you to host images in Val Town's blob storage, either by providing a URL or uploading directly from your device.

Features

  • Multiple Upload Methods:
    • Upload images from a URL
    • Upload images directly from your device
  • API Access:
    • RESTful API for programmatic image hosting
    • Comprehensive API documentation
  • Image Management:
    • Permanent storage in Val Town's blob storage
    • Unique URLs for each hosted image
    • Image metadata retrieval

How It Works

  1. Upload an Image:
    • Provide a URL to an existing image, OR
    • Upload an image file from your device
  2. Storage:
    • The image is downloaded/processed and stored in Val Town's blob storage with a unique key
  3. Access:
    • A permanent URL is generated for accessing the image
    • The image can be embedded in websites, shared, or accessed via API

API Documentation

POST /api/upload

Upload an image from a URL.

Request Body (JSON):

{ "url": "https://example.com/image.jpg" }

Response (Success):

{ "success": true, "key": "img_1234567890_abc123.jpg", "url": "https://your-val-town-url.com/view?key=img_1234567890_abc123.jpg", "contentType": "image/jpeg" }

GET /api/info

Get information about a hosted image.

Query Parameters:

  • key - The unique key of the image

Response (Success):

{ "success": true, "key": "img_1234567890_abc123.jpg", "contentType": "image/jpeg", "size": 12345, "url": "https://your-val-town-url.com/view?key=img_1234567890_abc123.jpg" }

GET /view

Retrieve and display a hosted image.

Query Parameters:

  • key - The unique key of the image

Response: The image with the appropriate content type.

Technical Details

  • Built using Val Town's HTTP endpoints
  • Uses Val Town's blob storage for image persistence
  • Handles various image formats (JPEG, PNG, GIF, WebP, SVG, BMP)
  • Preserves the original content type of the image

Limitations

  • Only works with publicly accessible image URLs for URL-based uploads
  • There may be size limitations based on Val Town's blob storage constraints
  • Only supports common image formats (JPEG, PNG, GIF, WebP, SVG, BMP)
HTTP
  • image-host.ts
    dcm31--44…44.web.val.run
Code
README.md
H
image-host.ts
Go to top
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Product
FeaturesPricing
Developers
DocsStatusAPI ExamplesNPM Package Examples
Explore
ShowcaseTemplatesNewest ValsTrending ValsNewsletter
Company
AboutBlogCareersBrandhi@val.town
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.