API v1.0 Docs

Working With Files

Listing your files

First, let's find out how you can list files that are accessible to an authenticated user (using its API Key).

The following request returns a paginated collection of files.

GET https://api.up2sha.re/files

Parameters

Name Type Description
visibility string Can be one of public, unlisted, private. Default: unlisted

Relationships

Here are the available relationships:

  • user
  • uploadKey

Example

Request Headers

The following request headers must be set.

Accept: application/vnd.u2s.v1+json
X-Api-Key: your_api_key

Here is how it works using curl.

curl -v \
     -H "Accept: application/vnd.u2s.v1+json" \
     -H "X-Api-Key: your_api_key" \
     "https://api.up2sha.re/files?include=uploadKey&limit=5&visiblity=private"

Response Body

The response body will be similar to this.

{
    "data": [
        {
            "id": 56883,
            "user_id": 1,
            "filename": "my_file.exe",
            "description": "My description",
            "size": null,
            "extension": "exe",
            "badge": "eWVRdv8VQoYi",
            "downloads": 0,
            "views": 0,
            "md5": null,
            "sha1": null,
            "sha256": null,
            "visibility": "private",
            "created_at": {
                "date": "2017-11-18 18:08:35.000000",
                "timezone_type": 3,
                "timezone": "UTC"
            },
            "updated_at": {
                "date": "2017-11-18 18:08:35.000000",
                "timezone_type": 3,
                "timezone": "UTC"
            },
            "viewed_at": null,
            "links": {
                "rel": "self",
                "uri": "/files/56883"
            },
            "uploadKey": {
                "id": 2,
                "file_id": 56883,
                "key": "AsxZ4NrQjFZaK5GbKNkGnKw5675mz3lo",
                "current_length": 2097152,
                "max_length": 10954725,
                "created_at": {
                    "date": "2017-11-18 18:08:37.000000",
                    "timezone_type": 3,
                    "timezone": "UTC"
                },
                "updated_at": {
                    "date": "2017-11-18 18:08:37.000000",
                    "timezone_type": 3,
                    "timezone": "UTC"
                },
                "links": {
                    "rel": "self",
                    "uri": "/upload-keys/2"
                }
            }
        }

        ...
    ],
    "meta": {
        "pagination": {
            "total": 45,
            "count": 5,
            "per_page": 5,
            "current_page": 1,
            "total_pages": 9,
            "links": {
                "next": "https://api.up2sha.re/files?limit=5&page=2"
            }
        }
    }
}

Updating file metadata

Not yet documented. Come back later!

Downloading a file

To download a file, you must first know its identifier. The file id can be retrieved after a successful upload process in the response's Location header, or by using the "Listing" endpoint, as described in the Listing your files section above.

Then, you need to retrieve its download_url attribute by sending a GET request to the following URL. In the URL, set the {fileId} value to the previously retrieved identifier.

GET /files/{fileId}

Request Headers

The following request headers must be set.

Accept: application/vnd.u2s.v1+json
X-Api-Key: your_api_key

Here is how it works using curl.

curl -v \
     -H "Accept: application/vnd.u2s.v1+json" \
     -H "X-Api-Key: your_api_key" \
     "https://api.up2sha.re/files/56883"

Response Body

{
    "id": 56883,
    "user_id": 1,
    "filename": "my_file.exe",

    ...

    "dowload_url": "https://up2sha.re/files/eWVRdv8VQoYi/download"
}

Finally, send a GET request to retrieved download url - see the download_url attribute shown above.

GET https://up2sha.re/files/eWVRdv8VQoYi/download

Here is how it works using curl.

curl -v \
     -o my_file.exe \
     "https://up2sha.re/files/eWVRdv8VQoYi/download"

Response Body

The response body contains the file contents.