Skip to content

Commit

Permalink
update with workaround file upload
Browse files Browse the repository at this point in the history
  • Loading branch information
shroominic committed Jun 13, 2024
1 parent 896ab78 commit 17c822e
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions examples/big_upload.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,36 @@
from codeboxapi import CodeBox


def url_upload(codebox, url: str) -> None:
codebox.run(
"""
import requests
def download_file_from_url(url: str) -> None:
response = requests.get(url, stream=True)
response.raise_for_status()
file_name = url.split('/')[-1]
with open('./' + file_name, 'wb') as file:
for chunk in response.iter_content(chunk_size=8192):
if chunk:
file.write(chunk)
"""
)
print(codebox.run(f"download_file_from_url('{url}')"))


with CodeBox() as codebox:
with open("examples/assets/swedata/train/data-00000-of-00001.arrow", "rb") as file:
codebox.upload(file.name, file.read(), timeout=900)
url_upload(
codebox,
"https://codeboxapistorage.blob.core.windows.net/bucket/data-test.arrow",
)
print(codebox.list_files())

url_upload(
codebox,
"https://codeboxapistorage.blob.core.windows.net/bucket/data-train.arrow",
)
print(codebox.list_files())

codebox.run("import os")
print(codebox.run("print(os.listdir())"))

0 comments on commit 17c822e

Please sign in to comment.