Package: vercel_storage
vercel-blobA wrapper around the vercel blob apiCurrent statusCurrently it only implements theVercel Blob API. You can use this package as a library as well as a command line utility.InstallationThis package is still unreleased. You can only install it locally.gitclonehttps://github.com/misaelnieto/vercel-storage.gitcdvercel-storage
pipinstall-e.Installation in development modeProbably only useful for the author and contributors.pipinstall-e'.[test]Run tests:pytestCommand line usageConfigurationYou must set theBLOB_READ_WRITE_TOKENenvironment variable to be able to use the library.exportBLOB_READ_WRITE_TOKEN="vercel_blob_rw_ABC1234XYz"Put operation$vercel_blobputdisk_dump.bin
----------------------------------------------------------------------------------------------------------------------
urlhttps://c6zu0uktwgrh0d3g.public.blob.vercel-storage.com/disk_dump-OTgBsduT0QQcfXImNMZky1NSy3HfML.bin
pathnamedisk_dump.bin
contentTypeapplication/octet-stream
contentDispositionattachment;filename="disk_dump.bin"----------------------------------------------------------------------------------------------------------------------You can also print the output information as a json:$vercel_blob--jsonputdisk_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_blobput--no-suffixchart.png-----------------------------------------------------------------------------------
urlhttps://c6zu0uktwgrh0d3g.public.blob.vercel-storage.com/chart.png
pathnamechart.png
contentTypeimage/png
contentDispositionattachment;filename="chart.png"-----------------------------------------------------------------------------------List operationThe list method returns a list of blob objects in a Blob store. For example, let's upload a file to the bob store:vercel_blobputprofile.png--------------------------------------------------------------------------------------------------------------------
urlhttps://c6zu0uktwgrh0d3g.public.blob.vercel-storage.com/profile-OtpJ1AUIxChAA6UZejVXPA1pkuBw2D.png
pathnameprofile.png
contentTypeimage/png
contentDispositionattachment;filename="profile.png"--------------------------------------------------------------------------------------------------------------------Now you can see your file on your blob store:vercel_bloblist
PathnameSizeinbytesurl
---------------------------------------------------------------------------------------------
profile.png11211https://c6zu0uktwgrh0d3g.public.blob.vercel-storage.com/profile-OtpJ1AUIxChAA6UZejVXPA1pkuBw2D.pngCopy operation$vercel_blobcopyhttps://c6zu0uktwgrh0d3g.public.blob.vercel-storage.com/disk_dump-0eX9NYJnZjO31GsDiwDaQ6TR9QnWkH.binfile.zip

----------------------------------------------------------------------------------
urlhttps://c6zu0uktwgrh0d3g.public.blob.vercel-storage.com/file.zip
pathnamefile.zip
contentTypeapplication/octet-stream
contentDispositionattachment;filename="file.zip"----------------------------------------------------------------------------------You can also print the output information as a json:$vercel_blob--jsoncopyhttps://c6zu0uktwgrh0d3g.public.blob.vercel-storage.com/disk_dump-0eX9NYJnZjO31GsDiwDaQ6TR9QnWkH.binfile.zip{'url':'https://c6zu0uktwgrh0d3g.public.blob.vercel-storage.com/file.zip','pathname':'file.zip','contentType':'application/octet-stream','contentDisposition':'attachment; filename="file.zip"'}Delete operationThe delete operation always suceeds, regardless of whether the blob exists or not. It returns a null payload.$vercel_blobdeletehttps://c6zu0uktwgrh0d3g.public.blob.vercel-storage.com/disk_dump-mSjTcLOIg8hlGNiWpWMUcGqVll1uST.binHead operationThe head operation returns a blob object's metadata.$vercel_blobheadhttps://c6zu0uktwgrh0d3g.public.blob.vercel-storage.com/file.zip
----------------------------------------------------------------------------------
urlhttps://c6zu0uktwgrh0d3g.public.blob.vercel-storage.com/file.zip
pathnamefile.zip
contentTypeapplication/octet-stream
contentDispositionattachment;filename="file.zip"uploadedAt2023-11-16T23:53:25.000Z
size1998cacheControlpublic,max-age=31536000,s-maxage=300----------------------------------------------------------------------------------As with the other commands, you can generate json output:$vercel_blob--jsonheadhttps://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 codeList operationNote:vercel_storagewill look for theBLOB_READ_WRITE_TOKENenvironment 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 operationfromvercel_storageimportblobmy_file='/path/to/file.zip'withopen(my_file,'rb')asfp:resp=blob.put(pathname=my_file,body=fp.read())Note:vercel_storagewill look for theBLOB_READ_WRITE_TOKENenvironment 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 operationretval=blob.copy(blob_url,to_path)# orretval=blob.copy(blob_url,to_path,options={"token":"ABCD123foobar"})Delete operationblob.delete(blob_url)# orblob.delete(blob_url,options={'token':'ABCD123foobar'})Head operationblob.head(blob_url)# orblob.head(blob_url,options={'token':'ABCD123foobar'})