File Sharing
  • iOS
  • Android
  • Web : JavaScript
  • Electron
  • Windows
  • macOS
  • Overview
  • SDK Downloads
  • Demo APP
  • Sample Codes
  • Access Guide
  • Quick Starts
  • Scene Practices
  • Advanced Features
  • Error Codes
  • Server API
  • Documentation
  • File Sharing
  • Sample Codes
Sample code
GitHub
Note
  • The sample code package is only for demonstrating the features of collaborative whiteboard and file sharing products. It can be used as a reference to assist with your development. However, the codes provided in this package haven't been rigorously tested. If you plan to use them in a production environment, make sure you conduct sufficient testing before release to avoid any potential issues that may cause losses.
  • The codes in this package are written for desktop browsers only. If you need to use them for mobile browsers, you need to do the adaptation for mobile browsers by yourself.
  • ZEGO no longer classifies environments into production environments and testing environments. If you create your project in ZEGO Admin Console on/before 2021-11-16, refer to the Testing environment deprecation to upgrade the SDK and adjust related codes.

Run the sample code

1 Set up the development environment

A browser supported by ZEGO SDK has been installed, as shown in the following table:

Platform Browser Supported version
Windows Chrome Win7 or later.
macOS Chrome macOS 10.10 or later.
iOS Safari iOS 10.0 or later.
iOS WeChat embedded browser iOS 10.0 or later.
Android Chrome Android 8.0 or later.
Android WeChat embedded browser Android 8.0 or later.

2 Prerequisites

Before you begin, make sure you complete the following steps:

  1. Create a project in the ZEGO Admin Console and get the AppID and Server URL of your project. For details, see ZEGO Admin Console - Project management.
  2. Obtain the Token required to log in to the room. For details, see User privilege control. If you want to make it easier to try and test, you can go to the Admin Console to get temporary tokens.

The current product needs to be used with the Real-Time Audio and Video product. And the Web platform features of the Real-Time Audio and Video are not enabled by default. To use related features, you will need to contact ZEGO Technical Support to enable them first.

3 Run the sample code

  1. Modify the file platform/web/init.js to set the value of AppID and Token, which are required for initializing the SDK. You must use the AppID and Token obtained as instructed in the Prerequisites section above.
// APP account
var _openConfig = {
    appID: 0, // Fill in the AppID you get from the Admin Console. 
    token: '', // Fill in the Token used for identity authentication. To obtian it, refer to the [User privilege control] [https://doc-en.zego.im/article/11416]. If you want to make it easier to try and test, go to the Admin Console to get temporary tokens.
    fileListUrl: '',
    // Impory the SDK's relative path (relative path in index.html)
    SDKPathList: ['./sdk/ZegoExpressWhiteboardWeb.js', './sdk/ZegoExpressDocsWeb.js']
};
  1. Go to the project folder, double-click the file index.html to open it, and then enter the room number and user name to join the room.
Page Directory