Media Endpoints
Description of endpoints used to manage media uploads for posts on the DeSo blockchain
Upload Image
POST
/api/v0/upload-image
Uploads an image to be included in a post and returns the URL where the image is stored. This endpoint also handles the resizing of the image.
Note that the request body should have multipart/form-data
as the content type.
Endpoint implementation in backend.
Example usages in frontend: - Make request to Upload Image - Use UploadImage to upload an image when a user is making a post
Request Body
Name | Type | Description |
---|---|---|
UserPublicKeyBase58Check* | String | Public key of the user uploading the image. |
JWT* | String | JWT of the user uploading the image. |
file* | File | image file to upload. Must be gif, jpeg, png, or webp file. Must be less than 10 MB |
Upload Video
POST
/api/v0/upload-video
UploadVideo creates a one-time tokenized URL that can be used to upload larger video files using the tus protocol. The client uses the Location header in the response from this function to upload the file. The client uses the Stream-Media-Id header in the response from cloudflare to understand how to access the file for streaming.
For more details, see the Cloudflare documentation on direct creator uploads here
Endpoint implementation in backend.
For an example of uploading a video using this endpoint and the tus protocol, see the implementation in frontend. After the upload finishes, you can check if the video is ready to be streamed by hitting the Get Video Statusendpoint
Headers
Name | Type | Description |
---|---|---|
Upload-Length* | Number | Length of video to be uploaded in bytes |
Upload-Metadata | JSON | Arbitrary metadata values - see cloudflare documentation for more details |
The Location header specifies the one-time tokenized URL. The Stream-Media-Id header is the ID used to stream the video from cloudflare after uploading the video.
Get Video Status
GET
/api/v0/get-video-status/{videoId}
Get Video Status queries cloudflare's API to see if a video is ready to be streamed. This is useful in showing a preview of an uploaded video to an end-user when they are creating a post.
Endpoint implementation in backend.
Example usage in frontend: - Make request to Get Video Status - Use GetVideoStatus to poll and see if a video is ready to be streamed after a user finished uploading it.
Path Parameters
Name | Type | Description |
---|---|---|
videoId* | String | videoId retrieved from the |
Get Full TikTok URL
POST
/api/v0/get-full-tiktok-url
Given a short video ID of a TikTok, find the URL that can be used to embed this video. The short URL users get when copying a link to a TikTok from TikTok's mobile app isn't embeddable, so this endpoint allows us to find the desktop version of the URL from which we can construct an embeddable version of the URL.
Endpoint implementation in backend.
Example usages in frontend: - Make request to Get Full TikTok URL - Use GetFullTikTokURL to get an embeddable URL for the short form TikTok url
Request Body
Name | Type | Description |
---|---|---|
TikTokShortVideoID* | String | Video ID found at the end of a URL copied from the TikTok mobile app. For example, |
Last updated