Skip to main content

vercel-blob

A wrapper around the vercel blob api

Lint and test

Current status

Currently it only implements the Vercel Blob API. You can use this package as a library as well as a command line utility.

Installation

This package is still unreleased. You can only install it locally.

git clone https://github.com/misaelnieto/vercel-storage.git
cd vercel-storage
pip install -e .

Installation in development mode

Probably only useful for the author and contributors.

pip install -e '.[test]

Run tests:

pytest

Command line usage

Configuration

You must set the BLOB_READ_WRITE_TOKEN environment variable to be able to use the library.

export BLOB_READ_WRITE_TOKEN="vercel_blob_rw_ABC1234XYz"

Put operation

$ vercel_blob put disk_dump.bin
------------------  ----------------------------------------------------------------------------------------------------
url                 https://c6zu0uktwgrh0d3g.public.blob.vercel-storage.com/disk_dump-OTgBsduT0QQcfXImNMZky1NSy3HfML.bin
pathname            disk_dump.bin
contentType         application/octet-stream
contentDisposition  attachment; filename="disk_dump.bin"
------------------  ----------------------------------------------------------------------------------------------------

You can also print the output information as a json:

$ vercel_blob --json put disk_dump.bin
{'url': 'https://c6zu0uktwgrh0d3g.public.blob.vercel-storage.com/disk_dump-0eX9NYJnZjO31GsDiwDaQ6TR9QnWkH.bin', 'pathname': 'disk_dump.bin', 'contentType': 'text/plain', 'contentDisposition': 'attachment; filename="disk_dump.bin"'}

By default, Vercel's blob store will insert a randomly generated string to the name of your file. But you can turn off that feature:

$ vercel_blob put --no-suffix chart.png 
------------------  -----------------------------------------------------------------
url                 https://c6zu0uktwgrh0d3g.public.blob.vercel-storage.com/chart.png
pathname            chart.png
contentType         image/png
contentDisposition  attachment; filename="chart.png"
------------------  -----------------------------------------------------------------

List operation

The list method returns a list of blob objects in a Blob store. For example, let's upload a file to the bob store:

vercel_blob put profile.png 
------------------  --------------------------------------------------------------------------------------------------
url                 https://c6zu0uktwgrh0d3g.public.blob.vercel-storage.com/profile-OtpJ1AUIxChAA6UZejVXPA1pkuBw2D.png
pathname            profile.png
contentType         image/png
contentDisposition  attachment; filename="profile.png"
------------------  --------------------------------------------------------------------------------------------------

Now you can see your file on your blob store:

vercel_blob list
Path name      Size in bytes  url
-----------  ---------------  -------------------------------------------------------------------
profile.png            11211  https://c6zu0uktwgrh0d3g.public.blob.vercel-storage.com/profile-OtpJ1AUIxChAA6UZejVXPA1pkuBw2D.png

Copy operation

$ vercel_blob copy https://c6zu0uktwgrh0d3g.public.blob.vercel-storage.com/disk_dump-0eX9NYJnZjO31GsDiwDaQ6TR9QnWkH.bin file.zip

------------------  ----------------------------------------------------------------
url                 https://c6zu0uktwgrh0d3g.public.blob.vercel-storage.com/file.zip
pathname            file.zip
contentType         application/octet-stream
contentDisposition  attachment; filename="file.zip"
------------------  ----------------------------------------------------------------

You can also print the output information as a json:

$ vercel_blob --json copy https://c6zu0uktwgrh0d3g.public.blob.vercel-storage.com/disk_dump-0eX9NYJnZjO31GsDiwDaQ6TR9QnWkH.bin file.zip
{'url': 'https://c6zu0uktwgrh0d3g.public.blob.vercel-storage.com/file.zip', 'pathname': 'file.zip', 'contentType': 'application/octet-stream', 'contentDisposition': 'attachment; filename="file.zip"'}

Delete operation

The delete operation always suceeds, regardless of whether the blob exists or not. It returns a null payload.

$ vercel_blob delete https://c6zu0uktwgrh0d3g.public.blob.vercel-storage.com/disk_dump-mSjTcLOIg8hlGNiWpWMUcGqVll1uST.bin

Head operation

The head operation returns a blob object's metadata.

$ vercel_blob head https://c6zu0uktwgrh0d3g.public.blob.vercel-storage.com/file.zip
------------------  ----------------------------------------------------------------
url                 https://c6zu0uktwgrh0d3g.public.blob.vercel-storage.com/file.zip
pathname            file.zip
contentType         application/octet-stream
contentDisposition  attachment; filename="file.zip"
uploadedAt          2023-11-16T23:53:25.000Z
size                1998
cacheControl        public, max-age=31536000, s-maxage=300
------------------  ----------------------------------------------------------------

As with the other commands, you can generate json output:

$ vercel_blob --json head https://c6zu0uktwgrh0d3g.public.blob.vercel-storage.com/file.zip
{'url': 'https://c6zu0uktwgrh0d3g.public.blob.vercel-storage.com/file.zip', 'pathname': 'file.zip', 'contentType': 'application/octet-stream', 'contentDisposition': 'attachment; filename="file.zip"', 'uploadedAt': '2023-11-16T23:53:25.000Z', 'size': 1998, 'cacheControl': 'public, max-age=31536000, s-maxage=300'}

Using vercel_storage in your python code

List operation

Note: vercel_storage will look for the BLOB_READ_WRITE_TOKEN environment variable. If it is not available it will raise an Exception.

If you have the token stored somewhere else, you can pass it directly to the put() function like this:

    resp = blob.list(options={'token': 'ABCD123foobar'})

Put operation

from vercel_storage import blob

my_file = '/path/to/file.zip'
with open(my_file, 'rb') as fp:
    resp = blob.put(
        pathname=my_file,
        body=fp.read()
    )

Note: vercel_storage will look for the BLOB_READ_WRITE_TOKEN environment variable. If it is not available it will raise an Exception.

If you have the token stored somewhere else, you can pass it directly to the put() function like this:

  resp = blob.put(
      pathname=my_file,
      body=fp.read(),
      options={'token': 'ABCD123foobar'}
  )

Copy operation

retval = blob.copy(blob_url, to_path)
# or
retval = blob.copy(blob_url, to_path, options={"token": "ABCD123foobar"})

Delete operation

blob.delete(blob_url)
# or
blob.delete(blob_url, options={'token': 'ABCD123foobar'})

Head operation

blob.head(blob_url)
# or
blob.head(blob_url, options={'token': 'ABCD123foobar'})

Metadata

Release files for vercel_storage 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vercel_storage 0.0.1
File Size Uploaded Provenance
vercel_storage-0.0.1.tar.gz 12.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for vercel_storage 0.0.1
File Interpreter ABI Platform
vercel_storage-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 21.8 kB

Release files / vercel_storage-0.0.1.tar.gz

Download URL vercel_storage-0.0.1.tar.gz
Size 12.4 kB
Tags Source
SHA-256 checksum
How to use checksums
f286e9190f70fa02dd4a2ab4b3d98462d8c41cff2251bdc4ab76793f115f97e1
BLAKE2b-256 checksum
How to use checksums
a8864e26a30405e873f191bac1fc7576b68d804ffc77177dd51fc9e97b0a6fef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.31.0

Release files / vercel_storage-0.0.1-py3-none-any.whl

Download URL vercel_storage-0.0.1-py3-none-any.whl
Size 9.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bf27be00ce9c648c665c726eeebffe8e2205cc9f991ed8ca7f2d356e42c1e2c1
BLAKE2b-256 checksum
How to use checksums
93bf6b879c383169117cfd5166fbba6d5cf6dacffd47689edd777991aec06279
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.31.0

Security for vercel_storage 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page