Helpful PHP Scripts Pt 2 - Upload Videos from an FTP Server
January 28, 2021 - Erikka Innes in Video upload, PHP
We're back with more helpful PHP scripts from Hervé Pita! If you have video content on an FTP server, you can use this script to move your files from there to api.video.
This script is part of a collection of scripts that help with bulk video uploads. Everything is available in our Helpful PHP Scripts repository on Github. In each part of this series, we'll walk through how to set up one of the scripts. What you'll find includes:
- Ingest Videos from Google Drive - You can transfer all your videos from a folder in Google Drive to your api.video account with this CLI script.
- Ingest Videos from an FTP Server - Transfer all your videos from the FTP server of your choice to your api.video account.
- Export All Your Video Data to .csv - With this script you can grab details about each video in your api.video account and gather it in one .csv spreadsheet.
- Update Metadata for api.video Videos Using CSV - You can update your metadata in bulk with this script.
- Update Video Settings in Bulk Without a CSV File - Update videos to all be public or private or offer an mp4 download or disable an mp4 download.
Today we're going to learn how to use the script for ingesting videos from an FTP server. Let's get started!
Prerequisites for Upload Videos from an FTP Server
For this project, you'll need to ensure that you have:
- PHP 5.4 or greater with the command-line interface (CLI) and JSON extension installed
- The Composer dependency management tool (or another way to manage your dependency management). See the Composer website for installation options.
- A GitHub account
- An Api.video account
- Your API key for either production or sandbox
- An FTP server account
You can also check out the API reference documentation for uploading a video here: Upload a video
- Navigate to the Helpful PHP Scripts repository.
- Click Code and from the drop-down click Download ZIP. (You can also install from the CLI if you prefer.)
- Put the contents of your new .zip file in a folder you want to work from.
- Navigate to the folder containing the contents of your zip file in the terminal.
- In the terminal, type:
composer require api-video/php-sdk
Try the Script
- You're asked what environment you want to use, prod or sandbox. For our walkthrough, choose prod. NOTE: Make sure you have the correct API key, they are different for production and sandbox. Production is better because there is no watermark across your videos. In sandbox mode, all transferred videos will say 'FOR DEVELOPMENT PURPOSES ONLY' across them.
- You're asked to provide your API key, go ahead and paste in your Production API key. If you weren't sure where to get it from, navigate to my.api.video and grab the key from the Production section on the Overview page.
- If authentication is successful, you are next asked if you want to associate a playerID with your videos. You can customise and brand players, then associate them with videos if you like. (View a tutorial about video player customisation here.) For the sake of simplicity, we'll skip this. Type n.
- Now you're asked to provide the address for your FTP server. Type the complete address, exactly as it appears, or paste it in.
- Enter your FTP username.
- Enter your FTP password.
- Provide the path to the video folder on your FTP server that you want to use for the transfer.
- The script will now step through all your files and upload any videos it finds to api.video. You receive a note after each file is successfully written to api.video.
That's all for this installment of helpful PHP scripts! More to come!
You may also like
in Android, Video upload, Kotlin
in Video upload, Android, Kotlin
in Player SDK, video create, Video list, Video upload, Player, Mobile, React, Typescript, Next.js