Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: Add guide to integrate videos uploader #57

Merged
merged 1 commit into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions docs/embedded-uploader/embedded-uploader.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Embedded Uploader


### Introduction
The TPStreams Uploader allows you to embed a powerful video upload tool directly on your website. With this integration, you can upload videos directly to your TPStreams account without needing to navigate away from your site, making the experience smooth and efficient. Whether you're embedding the uploader on a standalone page or in a modal, this guide will walk you through each step to get it up and running.

![Uploader UI](./img/uploader_step_1.png)



## Guide to integrate the uploader
This guide will help you integrate the TPStreams video uploader into your website allowing you to upload videos directly to your TPStreams account.


### Step 1: Get the Authentication Token
Use the API mentioned [here](../server-api/authentication.md) to obtain a user authentication token. This token is required for the uploader to authenticate uploads.


### Step 2: Import the TPStreams Uploader SDK
Include the TPStreams Uploader SDK script in your webpage. Add the following `<script>` tag in the `<head>` or right after the starting `<body>` tag:

```html
<script src="https://static.testpress.in/static/js/tpstreams-uploader.min.js"></script>
```


### Step 3: Add the TPStreams Uploader HTML Element
Place the following HTML tag where you want the uploader to appear on your webpage, including any modals if needed.
Make sure to replace the organization-id attribute with your own TPStreams organization ID.

```html
<tpstreams-uploader organization-id="your-organization-id"></tpstreams-uploader>
```

<b>Note:</b> This tag also supports `width` and `height` attributes if you need to customize the dimensions of the uploader UI.


### Step 4: Initialize the Uploader
When you are ready to display the uploader, execute the following JavaScript to initialize it with the authentication token:

```html
<script>
const tpstreamsUploader = document.querySelector('tpstreams-uploader');
tpstreamsUploader.authToken = '<authentication token>'; // Use token from Step 1
tpstreamsUploader.initialize();
</script>
```


### Full Example Code
The following code will display the TPStreams uploader UI on your webpage, allowing users to upload videos directly to your account.

```html
<html>
<head>
<!-- TPStreams Uploader SDK -->
<script src="https://static.testpress.in/static/js/tpstreams-uploader.min.js"></script>
</head>
<body>

<!-- TPStreams Uploader Element -->
<tpstreams-uploader organization-id="cmcktz"></tpstreams-uploader>

<!-- Initialization Script -->
<script>
const uploader = document.querySelector('tpstreams-uploader');
uploader.authToken = '<authentication token>'; // Replace with the actual token
uploader.initialize();
</script>

</body>
</html>
```


### Domain Restrictions for Embedding
In TPStreams settings, you can restrict the allowed domains that can embed this uploader. Set the allowed domain(s) to ensure only specified sites can use your uploader. If no domain is specified, all domains are permitted by default.

![Domain Restriction](./img/uploader_allowed_domains.png)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/embedded-uploader/img/uploader_step_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ const config = {
sidebarId: 'videoEmbeddingSidebar',
label: 'Video Embedding',
},
{
type: 'docSidebar',
position: 'left',
sidebarId: 'uploaderSidebar',
label: 'Embedded Uploader',
},
{
type: 'docSidebar',
position: 'left',
Expand Down
6 changes: 6 additions & 0 deletions sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ const sidebars = {
dirName: 'live-stream-api',
},
],
uploaderSidebar: [
{
type: 'autogenerated',
dirName: 'embedded-uploader',
},
],
};

module.exports = sidebars;
Loading