Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add multi-file upload capability to SDKs #503

Closed
wants to merge 8 commits into from

Conversation

0div
Copy link
Contributor

@0div 0div commented Dec 11, 2024

Description

Update the js-sdk write method to work as follows and adapt tests

import { Sandbox } from 'e2b'

const sbx = await Sandbox.create()

const infos = sbx.files.write([
    { path: "/path/to/a", data: "<blob>" },
    { path: "/path/to/b", data: "<blob>" },
], filesystemRequestOpts)

console.log('Files created', infos)
// [
//     { "name": "a", "path": "/path/to/a" },
//     { "name": "b", "path": "/path/to/b" }
//  ]

Upadte the python-sdk write method as well

from e2b import Sandbox

sbx = Sandbox()

files = []
for i in range(10):
    path = f"test_write_{i}.txt"
    content = f"This is a test file {i}."
    files.append({"path": path, "data": content})

infos = sbx.files.write(files)
print('Files created', infos)
# [
#   { "name": "a", "path": "/path/to/a" },
#   { "name": "b", "path": "/path/to/b" }
#  ]

Test

cd packages/js-sdk
pnpm test

cd packages/python-sdk
pnpm test

Copy link

changeset-bot bot commented Dec 11, 2024

🦋 Changeset detected

Latest commit: 832caa9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@e2b/python-sdk Major
e2b Major
@e2b/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@mlejva
Copy link
Member

mlejva commented Dec 11, 2024

@0div please also add/update docs to reflect the breaking change once the SDK ergonomics are set

@0div 0div requested a review from mlejva December 12, 2024 21:11
@0div
Copy link
Contributor Author

0div commented Dec 12, 2024

per discussion, moving towards overloading approach
#451

@0div 0div closed this Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants