In order to move data from your legacy system's current data store to PubNub's Storage requires that you create a batch process.


IMPORTANT CONSIDERATIONS

  • You have to contact PubNub Support to configure your keys to allow this behavior. Ask support to enable your key set (provide your sub-key) for PTTO (publish timetoken override).
  • The ptto value must be a 17 digit PubNub timetoken that is not older than your Storage & Playback add-on's retention property. It is likely you require setting it to Unlimited since you are importing data for the purpose of not losing that history after the migration. Review this StackOverflow thread for converting a timestamp to a PubNub 17-digit timetoken.
  • If PubNub Access Manager add-on is enabled, you must be sure that you are using your PubNub secret key so that the batch process has full permissions to all channels without the need to grant permissions to those channels first. Your server must be secure so that the secret key is not exposed to the public.


REST API

When you implement your batch process that performs this data migration, you will have to use REST calls as there are no current SDK APIs that support the ptto query parameter of the publish API.


WRITE

This is just a publish that specifies the timetoken to use to store the message with the norep flag enabled. 

http://pubsub.pubnub.com/publish/[your-publish-key]/[your-sub-key]/0/[channel]/0/[message]?ptto=[overriding-timetoken]&norep=1


READ

https://ps.pndsn.com/v3/history/sub-key/[yourSubKey]/channel/[channel-name]?max=1&reverse=false&end=[publish-timetoken]&include_meta=true


This is just a standard history call for a single message using its publish timetoken. 

The timetoken is the message's primary key in the channel, for example: 14184108487864105. When you publish new messages, the timetoken that is returned in the success callback is the timetoken used to retrieve that message from storage.