API
Ymage has a programmatic interface to upload files.
To upload a file, send a POST request to https://img.fym.one/
.
Content-Type
You can use multipart/form-data format to upload a file, which the parameter file
contains the file content.
Alternatively, plain image binary (image/png, image/jpeg, image/gif, image/webp) can also be POSTed.
Accept
The Accept
header in the request instructs the server which Content-Type you want to get in the response. The available values are text/html, text/plain and application/json.
# The text response looks like this: Short URL: https://img.fym.one/o2rdt4.png Long URL: https://img.fym.one/a266fac8ac05a90e4c6d82057bf9976b5a349f0ed253abf0e46abb236750c655.png # Or if there's an error: Error: Failed to upload file. Please try again. # The JSON response looks like this: { "short_url": "https://img.fym.one/o2rdt4.png", "long_url": "https://img.fym.one/a266fac8ac05a90e4c6d82057bf9976b5a349f0ed253abf0e46abb236750c655.png" } # Or if there's an error: { "error": { "code": 400, "message": "Failed to upload file. Please try again." } }If the
Accept
header is not satifiable. It will return HTML for User-Agent
s contains Mozilla
, text otherwise.
Examples
These examples use cURL to demonstrate the usage of this API.
$ curl -H 'Accept: text/plain' -F 'file=@file-to-upload.png' https://img.fym.one/ Short URL: https://img.fym.one/o2rdt4.png Long URL: https://img.fym.one/a266fac8ac05a90e4c6d82057bf9976b5a349f0ed253abf0e46abb236750c655.png $ curl -X POST -H 'Accept: application/json' --data-binary '@file-to-upload.png' https://img.fym.one/ { "short_url": "https://img.fym.one/o2rdt4.png", "long_url": "https://img.fym.one/a266fac8ac05a90e4c6d82057bf9976b5a349f0ed253abf0e46abb236750c655.png" }