Name | vercel_storage JSON |
Version |
0.0.1
JSON |
| download |
home_page | None |
Summary | A wrapper around the vercel storage blob api |
upload_time | 2023-11-17 01:51:30 |
maintainer | None |
docs_url | None |
author | None |
requires_python | ~=3.9 |
license | None |
keywords |
vercel
api
storage
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# vercel-blob
A wrapper around the vercel blob api
[![Lint and test](https://github.com/misaelnieto/vercel-storage/actions/workflows/python-app.yml/badge.svg?branch=main)](https://github.com/misaelnieto/vercel-storage/actions/workflows/python-app.yml)
## Current status
Currently it only implements the [Vercel Blob API](https://vercel.com/docs/storage/vercel-blob). 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.
```sh
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.
```sh
pip install -e '.[test]
```
Run tests:
```sh
pytest
```
## Command line usage
### Configuration
You must set the `BLOB_READ_WRITE_TOKEN` environment variable to be able to use the library.
```sh
export BLOB_READ_WRITE_TOKEN="vercel_blob_rw_ABC1234XYz"
```
### Put operation
```sh
$ 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:
```sh
$ 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:
```sh
$ 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:
```sh
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:
```sh
vercel_blob list
Path name Size in bytes url
----------- --------------- -------------------------------------------------------------------
profile.png 11211 https://c6zu0uktwgrh0d3g.public.blob.vercel-storage.com/profile-OtpJ1AUIxChAA6UZejVXPA1pkuBw2D.png
```
### Copy operation
```sh
$ 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:
```sh
$ 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.
```sh
$ 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.
```sh
$ 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:
```sh
$ 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:
```python
resp = blob.list(options={'token': 'ABCD123foobar'})
```
### Put operation
```python
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:
```python
resp = blob.put(
pathname=my_file,
body=fp.read(),
options={'token': 'ABCD123foobar'}
)
```
### Copy operation
```python
retval = blob.copy(blob_url, to_path)
# or
retval = blob.copy(blob_url, to_path, options={"token": "ABCD123foobar"})
```
### Delete operation
```python
blob.delete(blob_url)
# or
blob.delete(blob_url, options={'token': 'ABCD123foobar'})
```
### Head operation
```python
blob.head(blob_url)
# or
blob.head(blob_url, options={'token': 'ABCD123foobar'})
```
Raw data
{
"_id": null,
"home_page": null,
"name": "vercel_storage",
"maintainer": null,
"docs_url": null,
"requires_python": "~=3.9",
"maintainer_email": null,
"keywords": "vercel,api,storage",
"author": null,
"author_email": "Noe Nieto <nnieto@noenieto.com>",
"download_url": "https://files.pythonhosted.org/packages/a8/86/4e26a30405e873f191bac1fc7576b68d804ffc77177dd51fc9e97b0a6fef/vercel_storage-0.0.1.tar.gz",
"platform": null,
"description": "# vercel-blob\nA wrapper around the vercel blob api\n\n\n[![Lint and test](https://github.com/misaelnieto/vercel-storage/actions/workflows/python-app.yml/badge.svg?branch=main)](https://github.com/misaelnieto/vercel-storage/actions/workflows/python-app.yml)\n\n## Current status\n\nCurrently it only implements the [Vercel Blob API](https://vercel.com/docs/storage/vercel-blob). You can use this package as a library as well as a command line utility.\n\n## Installation\n\nThis package is still unreleased. You can only install it locally.\n\n```sh\ngit clone https://github.com/misaelnieto/vercel-storage.git\ncd vercel-storage\npip install -e .\n```\n\n### Installation in development mode\n\nProbably only useful for the author and contributors.\n\n```sh\npip install -e '.[test]\n```\n\nRun tests:\n\n```sh\npytest\n```\n\n## Command line usage\n\n### Configuration\n\nYou must set the `BLOB_READ_WRITE_TOKEN` environment variable to be able to use the library.\n\n```sh\nexport BLOB_READ_WRITE_TOKEN=\"vercel_blob_rw_ABC1234XYz\"\n```\n\n### Put operation\n\n```sh\n$ vercel_blob put disk_dump.bin\n------------------ ----------------------------------------------------------------------------------------------------\nurl https://c6zu0uktwgrh0d3g.public.blob.vercel-storage.com/disk_dump-OTgBsduT0QQcfXImNMZky1NSy3HfML.bin\npathname disk_dump.bin\ncontentType application/octet-stream\ncontentDisposition attachment; filename=\"disk_dump.bin\"\n------------------ ----------------------------------------------------------------------------------------------------\n```\n\nYou can also print the output information as a json:\n\n```sh\n$ vercel_blob --json put disk_dump.bin\n{'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\"'}\n```\n\nBy default, Vercel's blob store will insert a randomly generated string to the name of your file. But you can turn off that feature:\n\n```sh\n$ vercel_blob put --no-suffix chart.png \n------------------ -----------------------------------------------------------------\nurl https://c6zu0uktwgrh0d3g.public.blob.vercel-storage.com/chart.png\npathname chart.png\ncontentType image/png\ncontentDisposition attachment; filename=\"chart.png\"\n------------------ -----------------------------------------------------------------\n```\n\n### List operation\n\nThe list method returns a list of blob objects in a Blob store. For example, let's upload a file to the bob store:\n\n```sh\nvercel_blob put profile.png \n------------------ --------------------------------------------------------------------------------------------------\nurl https://c6zu0uktwgrh0d3g.public.blob.vercel-storage.com/profile-OtpJ1AUIxChAA6UZejVXPA1pkuBw2D.png\npathname profile.png\ncontentType image/png\ncontentDisposition attachment; filename=\"profile.png\"\n------------------ --------------------------------------------------------------------------------------------------\n```\n\nNow you can see your file on your blob store:\n\n```sh\nvercel_blob list\nPath name Size in bytes url\n----------- --------------- -------------------------------------------------------------------\nprofile.png 11211 https://c6zu0uktwgrh0d3g.public.blob.vercel-storage.com/profile-OtpJ1AUIxChAA6UZejVXPA1pkuBw2D.png\n```\n\n\n### Copy operation\n\n```sh\n$ vercel_blob copy https://c6zu0uktwgrh0d3g.public.blob.vercel-storage.com/disk_dump-0eX9NYJnZjO31GsDiwDaQ6TR9QnWkH.bin file.zip\n\n------------------ ----------------------------------------------------------------\nurl https://c6zu0uktwgrh0d3g.public.blob.vercel-storage.com/file.zip\npathname file.zip\ncontentType application/octet-stream\ncontentDisposition attachment; filename=\"file.zip\"\n------------------ ----------------------------------------------------------------\n\n```\n\nYou can also print the output information as a json:\n\n```sh\n$ vercel_blob --json copy https://c6zu0uktwgrh0d3g.public.blob.vercel-storage.com/disk_dump-0eX9NYJnZjO31GsDiwDaQ6TR9QnWkH.bin file.zip\n{'url': 'https://c6zu0uktwgrh0d3g.public.blob.vercel-storage.com/file.zip', 'pathname': 'file.zip', 'contentType': 'application/octet-stream', 'contentDisposition': 'attachment; filename=\"file.zip\"'}\n```\n\n### Delete operation\n\nThe delete operation always suceeds, regardless of whether the blob exists or not. It returns a null payload.\n\n```sh\n$ vercel_blob delete https://c6zu0uktwgrh0d3g.public.blob.vercel-storage.com/disk_dump-mSjTcLOIg8hlGNiWpWMUcGqVll1uST.bin\n```\n\n### Head operation\n\nThe head operation returns a blob object's metadata.\n\n\n```sh\n$ vercel_blob head https://c6zu0uktwgrh0d3g.public.blob.vercel-storage.com/file.zip\n------------------ ----------------------------------------------------------------\nurl https://c6zu0uktwgrh0d3g.public.blob.vercel-storage.com/file.zip\npathname file.zip\ncontentType application/octet-stream\ncontentDisposition attachment; filename=\"file.zip\"\nuploadedAt 2023-11-16T23:53:25.000Z\nsize 1998\ncacheControl public, max-age=31536000, s-maxage=300\n------------------ ----------------------------------------------------------------\n```\n\nAs with the other commands, you can generate json output:\n\n```sh\n$ vercel_blob --json head https://c6zu0uktwgrh0d3g.public.blob.vercel-storage.com/file.zip\n{'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'}\n```\n\n\n## Using vercel_storage in your python code\n\n### List operation\n\nNote: `vercel_storage` will look for the `BLOB_READ_WRITE_TOKEN` environment variable. If it is not available\nit will raise an Exception.\n\nIf you have the token stored somewhere else, you can pass it directly to the put() function like this:\n\n\n```python\n resp = blob.list(options={'token': 'ABCD123foobar'})\n```\n\n### Put operation\n\n```python\nfrom vercel_storage import blob\n\nmy_file = '/path/to/file.zip'\nwith open(my_file, 'rb') as fp:\n resp = blob.put(\n pathname=my_file,\n body=fp.read()\n )\n```\n\nNote: `vercel_storage` will look for the `BLOB_READ_WRITE_TOKEN` environment variable. If it is not available\nit will raise an Exception.\n\nIf you have the token stored somewhere else, you can pass it directly to the put() function like this:\n\n```python\n resp = blob.put(\n pathname=my_file,\n body=fp.read(),\n options={'token': 'ABCD123foobar'}\n )\n```\n\n### Copy operation\n\n```python\nretval = blob.copy(blob_url, to_path)\n# or\nretval = blob.copy(blob_url, to_path, options={\"token\": \"ABCD123foobar\"})\n```\n\n### Delete operation\n\n```python\nblob.delete(blob_url)\n# or\nblob.delete(blob_url, options={'token': 'ABCD123foobar'})\n```\n\n### Head operation\n\n```python\nblob.head(blob_url)\n# or\nblob.head(blob_url, options={'token': 'ABCD123foobar'})\n```\n\n",
"bugtrack_url": null,
"license": null,
"summary": "A wrapper around the vercel storage blob api",
"version": "0.0.1",
"project_urls": {
"Source": "https://github.com/misaelnieto/vercel-storage"
},
"split_keywords": [
"vercel",
"api",
"storage"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "93bf6b879c383169117cfd5166fbba6d5cf6dacffd47689edd777991aec06279",
"md5": "5a3ce9c40748e8940843ffd479dcf550",
"sha256": "bf27be00ce9c648c665c726eeebffe8e2205cc9f991ed8ca7f2d356e42c1e2c1"
},
"downloads": -1,
"filename": "vercel_storage-0.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "5a3ce9c40748e8940843ffd479dcf550",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": "~=3.9",
"size": 9382,
"upload_time": "2023-11-17T01:51:28",
"upload_time_iso_8601": "2023-11-17T01:51:28.212563Z",
"url": "https://files.pythonhosted.org/packages/93/bf/6b879c383169117cfd5166fbba6d5cf6dacffd47689edd777991aec06279/vercel_storage-0.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "a8864e26a30405e873f191bac1fc7576b68d804ffc77177dd51fc9e97b0a6fef",
"md5": "406adb7cd84cff7622e06cf298cc013e",
"sha256": "f286e9190f70fa02dd4a2ab4b3d98462d8c41cff2251bdc4ab76793f115f97e1"
},
"downloads": -1,
"filename": "vercel_storage-0.0.1.tar.gz",
"has_sig": false,
"md5_digest": "406adb7cd84cff7622e06cf298cc013e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "~=3.9",
"size": 12388,
"upload_time": "2023-11-17T01:51:30",
"upload_time_iso_8601": "2023-11-17T01:51:30.066790Z",
"url": "https://files.pythonhosted.org/packages/a8/86/4e26a30405e873f191bac1fc7576b68d804ffc77177dd51fc9e97b0a6fef/vercel_storage-0.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-11-17 01:51:30",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "misaelnieto",
"github_project": "vercel-storage",
"github_not_found": true,
"lcname": "vercel_storage"
}