Table of Contents
1. Introduction
Under one of video tutorial I recorded about bunny.net uploading movies directly from DropBox or Google Drive, You have asked me how to do it between bunny.net accounts itself. It is same like with others, just getting URL is different and I explained it already in this video. So let me show you how to put it all together.
2. Analyse old library.
2.1. Note down your credential
Open up your old library. In case you were using trial version that expired, your UI will be slow and you may see errors.
Do not worry. The only thing you need to get from here is API key so you can connect with Postman or curl. Visit API key page to get that key.
Note down your video library id. It is available in stream API section
2.2. Connect to API and get details
Now you can connect via API and get information about video library like storage ID.
curl --location 'https://api.bunny.net/videolibrary/117296' \
--header 'AccessKey: 9e1f62a6-2d28-4646-b039-c3afbd0da3f5'
response
{
"Id": 117296,
"Name": "Gees videos",
"VideoCount": 0,
"TrafficUsage": 19959720,
"StorageUsage": 560137002,
"DateCreated": "2023-04-25T12:39:03",
"ReplicationRegions": [
""
],
"ApiKey": "b952739c-f23c-4be1-a1cb4f915b3b-2d38-438e",
"ReadOnlyApiKey": "cd0d5a7b-80f9-4adc-9a3ae50e0607-fe33-4ac9",
"HasWatermark": false,
"WatermarkPositionLeft": 0,
"WatermarkPositionTop": 0,
"WatermarkWidth": 0,
"PullZoneId": 1363312,
"StorageZoneId": 268940,
...
In order to get details about Edge Storage API you can use storagezone call like below
curl --location 'https://api.bunny.net/storagezone/268940' \
--header 'AccessKey: 9e1f62a6-2d28-4646-b039-c3afbd0da3f5'
response
{
"Id": 268940,
"UserId": "0df505d4-d033-41c4-964a-6b2356214b92",
"Name": "vz-1d91ed2b-7d3",
"Password": "bc78aae2-5dd3-44cb-a88c2ef8d9f0-1ca8-48b3",
"DateModified": "2023-04-26T08:00:38",
"Deleted": false,
"StorageUsed": 560137002,
"FilesStored": 47,
"Region": "DE",
"ReplicationRegions": [],
"PullZones": [
{
"Id": 1363312,
"Name": "vz-1d91ed2b-7d3",
You have an access now to Edge Storage API with password from previous response. Use Pull Zone name as initial catalog to see whats there.
curl --location 'https://storage.bunnycdn.com/vz-1d91ed2b-7d3/' \
--header 'AccessKey: bc78aae2-5dd3-44cb-a88c2ef8d9f0-1ca8-48b3'
response
[
{
"Guid": "bb2f090f-4aca-4fda-8900-a0e6ead02c91",
"StorageZoneName": "vz-1d91ed2b-7d3",
"Path": "/vz-1d91ed2b-7d3/",
"ObjectName": "45f25b31-df60-4177-ac59-2ec91853d98a",
"Length": 0,
"LastChanged": "2023-04-25T13:09:35.203",
"ServerId": 0,
"ArrayNumber": 0,
"IsDirectory": true,
"UserId": "0df505d4-d033-41c4-964a-6b2356214b92",
"ContentType": "",
"DateCreated": "2023-04-25T13:09:35.203",
"StorageZoneId": 268940,
"Checksum": null,
"ReplicatedZones": null
}
]
Object Name here is type of directory (true) so you can explore further in order to find video files. Remember about slash at the end of line.
curl --location 'https://storage.bunnycdn.com/vz-1d91ed2b-7d3/45f25b31-df60-4177-ac59-2ec91853d98a/' \
--header 'AccessKey: bc78aae2-5dd3-44cb-a88c2ef8d9f0-1ca8-48b3'
response
[
{
"Guid": "fc009325-1f5f-4d18-8ea0-d1235723c3ec",
"StorageZoneName": "vz-1d91ed2b-7d3",
"Path": "/vz-1d91ed2b-7d3/45f25b31-df60-4177-ac59-2ec91853d98a/",
"ObjectName": "1280x720",
"Length": 0,
"LastChanged": "2023-04-25T13:34:23.629",
"ServerId": 0,
"ArrayNumber": 0,
"IsDirectory": true,
"UserId": "0df505d4-d033-41c4-964a-6b2356214b92",
"ContentType": "",
"DateCreated": "2023-04-25T13:34:23.629",
"StorageZoneId": 268940,
"Checksum": null,
"ReplicatedZones": null
},
{
...
{
"Guid": "be0d77e4-b072-44ea-ae8b-e90f6232735d",
"StorageZoneName": "vz-1d91ed2b-7d3",
"Path": "/vz-1d91ed2b-7d3/45f25b31-df60-4177-ac59-2ec91853d98a/",
"ObjectName": "original",
"Length": 494189856,
"LastChanged": "2023-04-25T13:21:18.659",
"ServerId": 601,
"ArrayNumber": 0,
"IsDirectory": false,
"UserId": "0df505d4-d033-41c4-964a-6b2356214b92",
"ContentType": "video/mp4",
"DateCreated": "2023-04-25T13:21:18.659",
"StorageZoneId": 268940,
"Checksum": "DFBDFAAAA5FD30998518482C0DF3E2E249D3B30EBAE60FA8485CC3BF393A7107",
"ReplicatedZones": ""
},
You will get multiple media files. If there is ObjectName equal to “original” then it means this is original uploaded file before transcoding. Good candidate to move it into new video library in new bunny.net account.
2.3. Prepare URL for fetching
You need direct link to download video file and that can be prepared by combination of API key, download param and path
https://storage.bunnycdn.com/vz-1d91ed2b-7d3/45f25b31-df60-4177-ac59-2ec91853d98a/original?AccessKey=bc78aae2-5dd3-44cb-a88c2ef8d9f0-1ca8-48b3&download
3. Prepare new library
Visit API key page in your new bunny.net account and note down API key. Then use it to create video library.
curl --location 'https://api.bunny.net/videolibrary' \
--header 'Content-Type: application/json' \
--header 'AccessKey: 9e1f62a6-2d28-4646-b039-c3afbd0da3f5' \
--data '{
"name":"migration_from_old"
}'
response
{
"Id": 262573,
"Name": "migration_from_old",
"VideoCount": 0,
"TrafficUsage": 0,
"StorageUsage": 0,
"DateCreated": "2024-06-29T16:47:33.2714592Z",
"ReplicationRegions": [
""
],
"ApiKey": "4125e327-ce88-42c4-affd9b288fc6-eacc-432c",
ApiKey from response you will use for Stream API to fetch video.
3.1. Fetching video – migration
Use below API call to download directly original video from old bunny account into newly created library.
curl --location 'https://video.bunnycdn.com/library/262573/videos/fetch' \
--header 'Content-Type: application/json' \
--header 'AccessKey: 4125e327-ce88-42c4-affd9b288fc6-eacc-432c' \
--data '{
"url": "https://storage.bunnycdn.com/vz-1d91ed2b-7d3/45f25b31-df60-4177-ac59-2ec91853d98a/original?AccessKey=bc78aae2-5dd3-44cb-a88c2ef8d9f0-1ca8-48b3&download"
}'
After quick processing is done you can see newly migrated video.
4. Final thoughts
In this knowledge article you have learned how to migrate video files from old bunny account into new bunny account. This trick works even if your old account is expired trial – at least as of now.
Now you can easily migrate your videos.
Have a nice coding!