List and manage stored files

Showing JavaScript examples.

This guide shows you how to list files uploaded to a channel and delete a file by its ID.

The examples on this page are written for the current SDK releases: C# 9.0.0, Dart 8.0.3, Go v10.0.0, Java 6.4.5, JavaScript 13.0.3, Kotlin 13.4.4, Objective-C 7.0.4, Python 10.7.2, and Swift 10.2.0. Each example assumes a PubNub client initialized for its SDK, unless the example sets one up itself.

Prerequisites:

  • File Sharing must be enabled on your keyset in the Admin Portal.
  • If Access Manager is enabled, the token must grant read on the channel to list files and delete to remove them.

List files​

A single list-files call returns up to 100 files for a channel. The response includes the file name, ID, size, and created timestamp for each file.

1const result = await pubnub.listFiles({ channel: 'my_channel' });

If more than 100 files exist on the channel, the response includes a more cursor. Pass it as next in a subsequent call to fetch the next page of results.

Delete a file​

To delete a file, you need the file ID and file name returned by listFiles or from the original upload response.

1

Deleting a file removes it from File Sharing storage. It does not remove the file event from Message Persistence history. If Message Persistence is enabled, the file event record remains in history after the file is deleted.

Was this page useful?

Last updated on