Skip to content

Latest commit

 

History

History
244 lines (193 loc) · 11.2 KB

File metadata and controls

244 lines (193 loc) · 11.2 KB
description Description of endpoints used to manage media uploads for posts on the DeSo blockchain

Media Endpoints

{% swagger method="post" path="" baseUrl="/api/v0/upload-image" summary="Upload Image" %} {% swagger-description %} 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 {% endswagger-description %}

{% swagger-parameter in="body" name="UserPublicKeyBase58Check" type="String" required="true" %} Public key of the user uploading the image. {% endswagger-parameter %}

{% swagger-parameter in="body" name="JWT" type="String" required="true" %} JWT of the user uploading the image. {% endswagger-parameter %}

{% swagger-parameter in="body" name="file" type="File" required="true" %} image file to upload. Must be gif, jpeg, png, or webp file. Must be less than 10 MB {% endswagger-parameter %}

{% swagger-response status="200: OK" description="Successfully uploaded image and response has URL at which image can be found" %} {% tabs %} {% tab title="Sample Response" %}

{
  "ImageURL": "https://images.deso.org/675fc5d13f397d6ce7801b0a76ca928822a768b606d16df1eb015b2e84ed81e5.gif"
}

{% endtab %}

{% tab title="Response Field Descriptions" %}

Name Type Description
ImageURL String URL at which the uploaded image can be found
{% endtab %}
{% endtabs %}
{% endswagger-response %}

{% swagger-response status="400: Bad Request" description="" %}

{
    // Response
}

{% endswagger-response %} {% endswagger %}

{% swagger method="post" path="" baseUrl="/api/v0/upload-video" summary="Upload Video" %} {% swagger-description %} 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 {% endswagger-description %}

{% swagger-parameter in="header" name="Upload-Length" type="Number" required="true" %} Length of video to be uploaded in bytes {% endswagger-parameter %}

{% swagger-parameter in="header" name="Upload-Metadata" type="JSON" %} Arbitrary metadata values - see

cloudflare documentation for more details

{% endswagger-parameter %}

{% swagger-response status="200: OK" description="Successfully created one-time tokenized URL that can be used to upload a video" %} 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. {% endswagger-response %}

{% swagger-response status="400: Bad Request" description="" %}

{
    // Response
}

{% endswagger-response %} {% endswagger %}

{% swagger method="get" path="" baseUrl="/api/v0/get-video-status/{videoId}" summary="Get Video Status" %} {% swagger-description %} 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. {% endswagger-description %}

{% swagger-parameter in="path" name="videoId" type="String" required="true" %} videoId retrieved from the

stream-media-id

header when uploading a video {% endswagger-parameter %}

{% swagger-response status="200: OK" description="Successfully queried Cloudflare for the status of the video" %} {% tabs %} {% tab title="Sample Response" %}

{
  "ReadyToStream": true // If true, video is ready to stream. If false, video is not ready to strea
}

{% endtab %}

{% tab title="Response Field Descriptions" %}

Name Type Description
ReadyToStream Boolean If true, the video is ready to be streamed. If false, the video is still being processed by cloudflare
{% endtab %}
{% endtabs %}
{% endswagger-response %}

{% swagger-response status="400: Bad Request" description="" %}

{
    // Response
}

{% endswagger-response %} {% endswagger %}

{% swagger method="post" path="" baseUrl="/api/v0/enable-video-download/{videoId}" summary="Enable A Video To Be Downloaded" %} {% swagger-description %} // // // EnableVideoDownload enables download support for an already uploaded video // Cloudflare does NOT allow uploaded videos to be downloaded (just streamed). Cloudflare allows adding download support on a per-video basis.

Enable A Video To Be Downloaded enables download support for an already uploaded video.

See Cloudflare documentation for more information.

Endpoint implementation in backend. {% endswagger-description %}

{% swagger-parameter in="path" name="videoId" type="String" required="true" %} videoId retrieved from the

stream-media-id

header when uploading a video {% endswagger-parameter %}

{% swagger-response status="200: OK" description="Successfully enabled video for downloading" %} {% tabs %} {% tab title="Sample Response" %}

{
  "Default":
    {
      "status": "ready",
      "url": "https://customer-<CODE>.cloudflarestream.com/<VIDEO_UID>/downloads/default.mp4",
      "percentComplete": 100.0
    }
}

{% endtab %}

{% tab title="Response Field Descriptions" %}

Name Type Description
Default Map A map that contains the video information. If downloading has been enabled, "url" indicates the path to the file
{% endtab %}
{% endtabs %}
{% endswagger-response %}

{% swagger-response status="400: Bad Request" description="" %}

{
    // Response
}

{% endswagger-response %} {% endswagger %}

{% swagger method="post" path="" baseUrl="/api/v0/get-full-tiktok-url" summary="Get Full TikTok URL" %} {% swagger-description %} 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 {% endswagger-description %}

{% swagger-parameter in="body" name="TikTokShortVideoID" type="String" required="true" %} Video ID found at the end of a URL copied from the TikTok mobile app.

For example, TTPd2Eobq3 is the VideoID in https://vm.tiktok.com/TTPd2Eobq3/\` {% endswagger-parameter %}

{% swagger-response status="200: OK" description="Successfully retrieved the embeddable version of the mobile TikTok URL provided" %} {% tabs %} {% tab title="Sample Response" %}

{
  "FullTikTokURL": "https://m.tiktok.com/v/7037137657872403718.html?_d=secCgYIASAHKAESPgo8T1WVnwCQv6PNczjlfPqZ%2BVrGtkECbrVIwDlSfs8Eubr5IYCCt7sen3HRJwDN44tt0IeLho5JoaUMWgAnGgA%3D&checksum=be13618b6e8d0eacdf95a8abd952ca14e997a5af0126908fb195dca7ab5082d5&language=en&preview_pb=0&sec_user_id=MS4wLjABAAAACRLophxm1bvJ6oYFi4m52AIzepq8Naslxs3ATZs1YCLXomDfhhDOvxsW9DemYFYU&share_app_id=1233&share_item_id=7037137657872403718&share_link_id=2E462ECA-A6B5-44CF-9A9A-BD3F25E5F6FF&source=h5_m&timestamp=1638557967&tt_from=copy&u_code=djcd82ge94k75m&user_id=6980837453575472134&utm_campaign=client_share&utm_medium=ios&utm_source=copy"
}

{% endtab %}

{% tab title="Response Field Descriptions" %}

Name Type Description
FullTikTokURL String Desktop version of the mobile TikTok URL provided in the request body that can be embedded in a post
{% endtab %}
{% endtabs %}
{% endswagger-response %}

{% swagger-response status="400: Bad Request" description="" %}

{
    // Response
}

{% endswagger-response %} {% endswagger %}