#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys

from versio9 import V1Meta

try:
    url, username, password = sys.argv[1:3]
except ValueError:
    print("Please supply command line arguments")

v1 = V1Meta(instance_url=url, username=username, password=password)

story = v1.Story.create(
        Name="New Story",
        Scope="Scope:0"
        # Scope = v1.Scope.where(Name="Product XYZ").first()
)

attachment = v1.Attachment.create(
        Name="New attachment",
        Content="",
        ContentType="application/octet-stream",
        Filename="test.dat",
        Asset=story
)

# right now, every access to the "file_data" property causes an HTTP request.
# in the future the SDK needs to cache this on reads and do dirty tracking / 
# commit managment for writes.

attachment.file_data = '\x00\xFF' * 20000

print len(attachment.file_data)
