From 1217f56f5e22011021efba5e857d9f1e5703214a Mon Sep 17 00:00:00 2001 From: gtwohig Date: Thu, 22 Sep 2016 17:50:43 -0400 Subject: [PATCH] moved examples to the client repo now they are here https://github.com/jwplayer/jwplatform-py/tree/master/examples --- .DS_Store | Bin 8196 -> 6148 bytes python-api-kit-examples/s3_upload.py | 56 --------------------------- 2 files changed, 56 deletions(-) delete mode 100644 python-api-kit-examples/s3_upload.py diff --git a/.DS_Store b/.DS_Store index 7b7c961b105fbbd39bdd1c5db7d13caeeb7ac8ca..d916327fdaa036061bfa2dee3073f46344823735 100644 GIT binary patch delta 104 zcmZp1XfcprU|?W$DortDU=RQ@Ie-{Mvv5r;6q~50$jH7iU^g=(`(_>iJEn~#dl?tA qb8rYU162Tl05_0u1u5QG_?>w&zl=E3MR&8wY371IXI*>O&xtB3u?O-Enc#8 z+42>Kj{@}p0V5-XW)OzbFzOhPL6VE=8H!VilXH^t^K(FElBAcRI49jOI5|JJ0A@Yu zCe-KVySSv3mLxMUTt3082R4XAN95+GkZ*!JI93WWDD}r?Yqm3t8yh?r1(_j%A;Ar# nT|p^mvmnQJ=E?jbo|FA~I5>cz3`$%KljC`&F*0r}WMu{b-1mXv diff --git a/python-api-kit-examples/s3_upload.py b/python-api-kit-examples/s3_upload.py deleted file mode 100644 index 3e3a3c0..0000000 --- a/python-api-kit-examples/s3_upload.py +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -import os -import logging - -import jwplatform -import requests - -logging.basicConfig(level=logging.INFO) - -def upload_video(api_key, api_secret, video_file): - - # Setup API client - jwplatform_client = jwplatform.Client(api_key, api_secret) - - # Make /videos/create API call - logging.info("creating video") - try: - response = jwplatform_client.videos.create( - title=os.path.basename(video_file), - upload_method='s3') - except jwplatform.errors.JWPlatformError as e: - logging.error("Encountered an error creating a video") - sys.exit(e.message) - logging.info(response) - - # Construct base url for upload - upload_url = '{}://{}{}'.format( - response['link']['protocol'], - response['link']['address'], - response['link']['path'] - ) - - # Query parameters for the upload - query_parameters = response['link']['query'] - - - # HTTP PUT upload using requests - with open(video_file, 'rb') as f: - r = requests.put(upload_url, params=query_parameters, data=f) - logging.info('uploading file {} to url {}'.format(video_file, r.url)) - logging.info('upload response: {}'.format(r.text)) - logging.info(r) - -if __name__ == '__main__': - import argparse - parser = argparse.ArgumentParser(description='Upload a file to JW Platform.') - parser.add_argument('api_key', type=str, - help='The API Key of your JW Platform account.') - parser.add_argument('api_secret', type=str, - help='The API Secret of your JW Platform account.') - parser.add_argument('video_file', type=str, - help='The path and file name you want to upload. ex: path/file.mp4') - args = parser.parse_args() - upload_video(args.api_key, args.api_secret, args.video_file)