Web SDK

The Newfang SDK for Web Apps.

Installation

Download your SDK from Dev Portalarrow-up-right and place it in your project code.

Usage

Getting Started

Add the libraries you need in your html.

//For single file downloads
<script src="../path/to/sdk/newfang-downloader.js"></script>
//For single file uploads
<script src="../path/to/sdk/newfang-uploader.js"></script>
//For single file deletion
<script src="../path/to/sdk/newfang_utils.js"></script>
//For generating URLs to place in HTML media tags
<script src="../path/to/sdk/newfang_store.js"></script>

Uploader

circle-info

Newfang uses a combination of your file's content hash and a convergence key to identify your file. The SDK exposes a method to generate this convergence key where you can specify:

App level convergence No duplication of any file across your app. Only a single copy of a specific file is stored. No need to call generate_convergence(). The SDK handles this. User level convergence No duplication of any file for a specific user. Different users can upload the same file and they would be treated as different copies. Call generate_convergence() once per user and store the convergence against a specific user. File level convergence All files are duplicated. The same user can upload the same file multiple times and they would be treated as separate copies. Call generate_convergence() each time you upload a file and store the convergence against that file.

Downloader

To download a single file.

Store

To dynamically generate one or more urls to place in HTML media tags(img/video/audio) and fetch the media file.

circle-info

Store is still in deep development at Newfang and unlike with Uploader/Downloader/Delete, you won't see any requests or charges on the developer portal.

Vanilla JS (without templating)

Vue

React

Delete

Remember

  • Call the convergence once or multiple times depending on your apps use case.

  • Pass in the correct convergence in order to correctly upload/delete a file.

  • Start the operations(upload/download/delete) after subscribing to its events.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

None

Last updated

Was this helpful?