This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ResponseIterator: | |
def __init__(self, response): | |
self.result_index = 0 | |
self.asset_index = 0 | |
self.total_assets = response.total | |
self.current_page = 1 | |
self.total_pages = response.total_pages | |
self.response = response |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Dir structure | |
xxhash_arm | |
setup.py | |
xxhash | |
__init__ | |
.so | |
.so name needs to match py version | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import math | |
class FrameioUploader(object): | |
def __init__(self, asset, file): | |
self.asset = asset | |
self.file = file | |
self.session = None | |
self.file_position = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def scan_frameio_project(client, parent_asset_id): | |
folder_assets = client.get_asset_children(parent_asset_id) | |
folders = [] | |
for a in folder_assets: | |
if a['type'] == 'file': | |
# Save asset somewhere, a['name'] | |
elif a['type'] == 'folder': | |
folders.append(a) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Prep before running this file | |
#apt update && apt install curl | |
#curl this files url --output some.file | |
# Dependencies | |
apt update | |
apt install -y build-essential wget openssh-server rsync vim zlib1g-dev git curl software-properties-common | |
add-apt-repository --yes ppa:fkrull/deadsnakes && apt-get update && apt-get install --yes python3.5 python3.5-dev | |
curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import frameioclient | |
from frameioclient.next_uploader import \ | |
NextFrameioUploader # Rename the uploader class in next file... | |
from frameioclient.py3_uploader import FrameioUploader | |
import mimetypes | |
import os | |
import xxhash | |
from time import sleep | |
KB = 1024 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Policy | |
Uploads | |
- Local files are considered ready for upload if their size hasn't changed in the last 60 secs. | |
- If the local xxhash does not match Frame.io's hash, the asset is deleted on Frame.io and re-uploaded. | |
- Assets are deleted and re-uploaded 3 times max. | |
Downloads | |
- Frame.io assets are considered ready for download when upload_completed_at is not None. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
service: s3-to-frameio-lambda-copy | |
frameworkVersion: '2' | |
provider: | |
name: aws | |
runtime: python3.8 | |
memorySize: 1024 | |
timeout: 900 | |
region: us-east-1 | |
iamRoleStatements: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lambda_client.invoke( | |
FunctionName='s3-to-frameio-lambda-copy-dev-copy', | |
InvocationType='Event', | |
Payload=json.dumps({ | |
'bucket_name': bucket, | |
'previous_asset': '', | |
'continued_run': 'false', | |
'parent_ids': {'': root_asset_id}}) # Dict with folder:asset_id pairs. '' is root. | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def copy(event, context): | |
"""Copy files and folders from S3 to Frame.io. Restart if Lambda timeouts""" | |
bucket_name = event['bucket_name'] | |
previous_asset = event['previous_asset'] | |
continued_run = event['continued_run'] | |
parent_ids = event['parent_ids'] | |
start_time = time() | |
previous_folder = '' |
OlderNewer