Skip to content

Commit

Permalink
Merge pull request #52 from ccnmtl/unique-manifest
Browse files Browse the repository at this point in the history
ensure manifests are unique
  • Loading branch information
nbuonin authored Jun 7, 2018
2 parents 6c99c43 + 71c27f5 commit c54bf63
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ node_modules
dist
pypanopto.egg-info
.pytest_cache
testbed.py
testbed.py
.settings
13 changes: 9 additions & 4 deletions panopto/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import math
import os
import re
import uuid

from boto.compat import BytesIO
from boto.s3.connection import S3Connection, OrdinaryCallingFormat
Expand Down Expand Up @@ -67,12 +68,16 @@ def __init__(self):
self.dest_filename = None
self.title = None
self.description = None
self.uuid = str(uuid.uuid4())

def set_destination_attributes(self):
if not self.dest_filename:
self.dest_filename = os.path.basename(self.input_file)
path, filename = os.path.split(self.input_file)

fname, ext = os.path.splitext(filename)
self.dest_filename = '{}{}'.format(self.uuid, ext)

if not self.title:
self.title = self.dest_filename
self.title = fname

def create_session(self):
# authenticate
Expand Down Expand Up @@ -185,7 +190,7 @@ def upload_manifest(self):

source_file = BytesIO(manifest.encode('utf-8'))

key_name = self.target.file_key('manifest.xml')
key_name = self.target.file_key('{}.xml'.format(self.uuid))
mp = self.bucket.initiate_multipart_upload(key_name)
mp.key_name = key_name

Expand Down

0 comments on commit c54bf63

Please sign in to comment.