{ "info": { "author": "George Sibble", "author_email": "gsibble@gmail.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.6", "Topic :: Software Development :: Libraries" ], "description": "# b2blaze \n![CircleCI](https://img.shields.io/circleci/project/github/sibblegp/b2blaze.svg)\n[![Code Coverage](https://scrutinizer-ci.com/g/sibblegp/b2blaze/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/sibblegp/b2blaze/?branch=master)\n\n\nWelcome to the b2blaze library for Python.\n\nBackblaze B2 provides the cheapest cloud object storage and transfer available on the internet. Comparatively, AWS S3 is 320% more expensive to store and 400% more expensive to transfer to the internet.\n\nThis library will allow you to easily interact with B2 buckets and files as first class objects in Python 2 and 3. It is licensed under the MIT license so feel free to use it anywhere! If you enjoy it, please feel free to contribute or request features.\n\n## Installation\n\nTo install b2blaze, run the following command in the proper environment:\n\n```bash\npip install b2blaze\n```\n\n## Setup\n\nYou will need a key_id and an application_key to run b2blaze. You can obtain these in the B2 portal. Then, either pass them into B2() or set the environment variables B2_KEY_ID and B2_APPLICATION_KEY.\n\n## Example Usage\n\nb2blaze is built around OOP principles and as such all buckets and files are objects which you can interact with. Let's see an example where we list all of our files in a bucket:\n\n```python\nfrom b2blaze import B2\nb2 = B2()\nbucket = b2.buckets.get('test_bucket')\nfiles = bucket.files.all()\n```\n\nFiles will be a list of B2File objects with all of their properties which can then be downloaded by running:\n\n```python\ncontent = files[0].download()\n```\n\nThis is a BytesIO object that you can manipulate in any way include saving locally or serving on a website.\n\n# Guide\n\n## The B2 Object\n\n```python\nfrom b2blaze import B2\nb2 = B2()\n```\nThe B2 object is how you access b2blaze's functionality. You can optionally pass in \"key_id\" and \"application_key\" as named arguments but you should probably set them as environment variable as described above.\n\n## Buckets\n\nBuckets are essentially the highest level folders in B2, similar to how buckets are used in AWS S3.\n\n#### Bucket Properties\n\n```python\nbucket_id\nbucket_name\nbucket_type\nbucket_info\nlifecycle_rules\nrevision\ncors_rules\ndeleted\n```\n\n#### List All Buckets\n\n```python\nbuckets = b2.buckets.all()\n```\n\n#### Create a Bucket\n\n```python\nbucket = b2.buckets.create('test_bucket', security=b2.buckets.public)\n```\n\nBuckets can either be public or private. This does not change the functionality of the library other than that you will need to manually authorize when using file URLs (see below).\n\n#### Retrieve a bucket\n\n```python\nbucket_by_name = b2.buckets.get('test_bucket')\nbucket_by_id = b2.buckets.get(bucket_id='abcd')\n```\n\n#### Delete a bucket\n\n```python\nbucket.delete()\n```\n\nThis will delete both the bucket and all files within it. There is no confirmation. Use carefully.\n\n## Files\n\nFiles are the same files you store locally. They can be stored inside folders placed in buckets but this means they simply have a name like \"folder/test.txt\". There is no distinction between folders and files.\n\n#### File Properties\n\n```python\nfile_id\nfile_name\ncontent_sha1\ncontent_length\ncontent_type\nfile_info\naction\nuploadTimestamp\ndeleted\n```\n\n#### List All Files in a Bucket\n\n```python\nbucket.files.all()\n```\n\nNOTE: There may be tens of thousands of files (or more) in a bucket. This operation will get information and create objects for all of them. It may take quite some time and be computationally expensive to run.\n\n#### Upload a File\n\n```python\ntext_file = open('hello.txt', 'rb')\nnew_file = bucket.files.upload(contents=text_file, file_name='folder/hello.txt')\n```\n\nNOTE: You don't have to call `.read()` and instead can send the file directly to contents. This will allow the file buffer directly over HTTP to B2 and save a significant amount of memory. Also, `contents` must be binary or a binary stream.\n\n#### Upload a Large File\n\n```python\nlarge_file = open('large_file.bin', 'rb')\nnew_file = bucket.files.upload_large_file(contents=large_file, file_name='folder/large_file.bin', num_threads=4)\n```\n\nNOTE: You cannot call `.read()` on the file because the function will seek and buffer the file over `num_threads` for you. Per [Backblaze recommendation](https://www.backblaze.com/b2/docs/large_files.html), `part_size` defaults to `recommendedPartSize` from `b2_authorize_account` (typically 100MB). `num_threads` defaults to 4 threads. The minimum part size is 5MB and you must have must have at least 2 parts.\n\n#### Retrieve a File's Information (Necessary before Downloading)\n\n```python\nfile_by_name = bucket.files.get(file_name='folder/hello.txt')\nfile_by_id = bucket.files.get(file_id='abcd1234')\n```\n\n#### Download a file\n\n````python\nfile = bucket.files.get(file_name='folder/hello.txt')\ndownloaded_file = file.download()\n````\n\nThis returns a BytesIO object which you can manipulate in Python using a tool like PIL, serve on a website, or easily save like this:\n\n```python\nsave_file = open('save_pic.jpg', 'wb')\nsave_file.write(downloaded_file.read())\nsave_file.close()\n```\n\n#### Delete a file version\n\n```python\nfile.delete()\n```\n\nThis deletes a single version of a file. (See the [docs on File Versions](https://www.backblaze.com/b2/docs/b2_delete_file_version.html) at Backblaze for explanation)\n\n#### Hide (aka \"Soft-delete\") a file\n\n```python\nfile.hide()\n```\n\nThis hides a file (aka \"soft-delete\") so that downloading by name will not find the file, but previous versions of the file are still stored. (See the [docs on Hiding file](https://www.backblaze.com/b2/docs/b2_hide_file.html) at Backblaze for details)\n\n## Testing\n\nUnit testing with pytest\nBefore running, you must set the environment variables: `B2_KEY_ID` and `B2_APPLICATION_KEY`\n\n** Run tests **\n\n``` bash\npython3 ./tests.py\n```\n\n\n## LICENSE\n\nMIT License\n\nCopyright (c) 2018 George Sibble\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/fieldse/b2blaze-fork", "keywords": "backblaze b2 cloud storage", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "b2blaze", "package_url": "https://pypi.org/project/b2blaze/", "platform": "", "project_url": "https://pypi.org/project/b2blaze/", "project_urls": { "Homepage": "https://github.com/fieldse/b2blaze-fork" }, "release_url": "https://pypi.org/project/b2blaze/0.2.1/", "requires_dist": [ "requests (==2.19.1)" ], "requires_python": ">=2.7", "summary": "Forked from George Sibble's B2Blaze (0.1.10). All credits to author. Original package: https://github.com/sibblegp/b2blaze", "version": "0.2.1" }, "last_serial": 4445667, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "96918a27cef9fe2954e2bebbb6e8278c", "sha256": "2bda2aa566dbe41db67bec294a7e27a2fff683d066f7ea90ef61eb73c3dbdc3f" }, "downloads": -1, "filename": "b2blaze-0.1.0.tar.gz", "has_sig": false, "md5_digest": "96918a27cef9fe2954e2bebbb6e8278c", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7", "size": 5497, "upload_time": "2018-06-25T20:30:12", "url": "https://files.pythonhosted.org/packages/92/d9/97d3a4fdd7e07f1f0802f24d11ef13e246b9e6dea84d29a88dbd197d45ac/b2blaze-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "95d09604b50190927138f77266621050", "sha256": "ce6a200bcf983a375396c88caeaeb56487fa6d2c025b4e7b52fd83dbf94526da" }, "downloads": -1, "filename": "b2blaze-0.1.1.tar.gz", "has_sig": false, "md5_digest": "95d09604b50190927138f77266621050", "packagetype": "sdist", "python_version": "source", "requires_python": "==2.7", "size": 5618, "upload_time": "2018-06-25T20:41:41", "url": "https://files.pythonhosted.org/packages/73/b8/cedfd9c84c0807c2796f1691bd0884e631690991664f6610844c3e7f1913/b2blaze-0.1.1.tar.gz" } ], "0.1.10": [ { "comment_text": "", "digests": { "md5": "e1cf89c298437e9691f3bbef05dbb7ff", "sha256": "3911e2a3e7f95fdfae8995c013937239dd24466008a36bfca025c566f328b7fe" }, "downloads": -1, "filename": "b2blaze-0.1.10.tar.gz", "has_sig": false, "md5_digest": "e1cf89c298437e9691f3bbef05dbb7ff", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7", "size": 12691, "upload_time": "2018-08-09T22:10:13", "url": "https://files.pythonhosted.org/packages/ee/c0/b14779335de1661e8f321f4cf298bf28383bb02504b9eb9918b432a80ec4/b2blaze-0.1.10.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "4a716f587d66180aecc595e12694807c", "sha256": "48c43ae48700e40a452176b6f77348aadcb97d3c69db02f54d1d6f35eabb1fd2" }, "downloads": -1, "filename": "b2blaze-0.1.2.tar.gz", "has_sig": false, "md5_digest": "4a716f587d66180aecc595e12694807c", "packagetype": "sdist", "python_version": "source", "requires_python": "==2.7", "size": 5837, "upload_time": "2018-06-25T22:41:06", "url": "https://files.pythonhosted.org/packages/b6/d2/9bf022695d03e354299cc53832b02d74e2d2d85038f54370b7b0729ad3b1/b2blaze-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "8eca926fafb95f2b697c74cc425f5def", "sha256": "715fb5049ac3daa493b3a3430e6526f49768046f66e4880fc7d4fab7bb99073e" }, "downloads": -1, "filename": "b2blaze-0.1.3.tar.gz", "has_sig": false, "md5_digest": "8eca926fafb95f2b697c74cc425f5def", "packagetype": "sdist", "python_version": "source", "requires_python": "==2.7", "size": 7049, "upload_time": "2018-06-25T23:06:07", "url": "https://files.pythonhosted.org/packages/00/95/14a4c462acc5126665a996fd69439c7ba440af28ac6a8a3dd7f464537788/b2blaze-0.1.3.tar.gz" } ], "0.1.4": [ { "comment_text": "", "digests": { "md5": "a8ab64702c324e475252c786352d9498", "sha256": "6a2b6f160673949b39b147230c22ba0c41a72aaa13580dd9e8f0595bb0188a92" }, "downloads": -1, "filename": "b2blaze-0.1.4.tar.gz", "has_sig": false, "md5_digest": "a8ab64702c324e475252c786352d9498", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7", "size": 5899, "upload_time": "2018-06-26T19:51:36", "url": "https://files.pythonhosted.org/packages/f4/62/4eb5ddbe1f301e1085ec242f39f510475ea4d3b67e075f96caf1aabd12af/b2blaze-0.1.4.tar.gz" } ], "0.1.5": [ { "comment_text": "", "digests": { "md5": "f149092db4788524319a849154ad444d", "sha256": "e5f9a16ca89d1a7763466d4f65fe240c03dc5a8bcf7a53536b8fa8eea68269ae" }, "downloads": -1, "filename": "b2blaze-0.1.5.tar.gz", "has_sig": false, "md5_digest": "f149092db4788524319a849154ad444d", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7", "size": 5891, "upload_time": "2018-06-26T19:57:33", "url": "https://files.pythonhosted.org/packages/b5/a3/dc5550b4845d85e59baa639262d3593f528c4a249d31930142db3426bd01/b2blaze-0.1.5.tar.gz" } ], "0.1.6": [ { "comment_text": "", "digests": { "md5": "88fb33987bbdaf3ed8192a9cf928cf5e", "sha256": "d10e4f7afd549a6a3bdd463c88df3e152d15815fd0a2294cf48cd7594b39db8f" }, "downloads": -1, "filename": "b2blaze-0.1.6.tar.gz", "has_sig": false, "md5_digest": "88fb33987bbdaf3ed8192a9cf928cf5e", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7", "size": 5897, "upload_time": "2018-06-26T20:20:21", "url": "https://files.pythonhosted.org/packages/7b/8e/b1624652cf95a9f5932b688ec46162c1ad876cc73249946f46e69446ab50/b2blaze-0.1.6.tar.gz" } ], "0.1.7": [ { "comment_text": "", "digests": { "md5": "3edc50e23bf4b9c7289681be68cddeee", "sha256": "58430d429cdc718515837c4c69344fbf9f610e188488158b2d095674b2250231" }, "downloads": -1, "filename": "b2blaze-0.1.7.tar.gz", "has_sig": false, "md5_digest": "3edc50e23bf4b9c7289681be68cddeee", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7", "size": 6045, "upload_time": "2018-06-27T19:23:49", "url": "https://files.pythonhosted.org/packages/d7/00/a99098d490ee6540070fbf18a1a00d27bdafb18bd3d0ca77ec4fcc527013/b2blaze-0.1.7.tar.gz" } ], "0.1.8": [ { "comment_text": "", "digests": { "md5": "5431a2db505b5e5767f34f292b470f2d", "sha256": "6ac364b3f6350c926efade5a89227f1459087f0e4ea17906fe5eb30794233601" }, "downloads": -1, "filename": "b2blaze-0.1.8.tar.gz", "has_sig": false, "md5_digest": "5431a2db505b5e5767f34f292b470f2d", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7", "size": 10183, "upload_time": "2018-07-05T17:27:56", "url": "https://files.pythonhosted.org/packages/50/d3/12434dd89bde491930a44157bcbee5c060b34d373ca5f586c74ecf678396/b2blaze-0.1.8.tar.gz" } ], "0.1.9": [ { "comment_text": "", "digests": { "md5": "05063a270758f5bcb2b8713a29a2d0db", "sha256": "9fb2531db22f71cca1c7b8cfd3b77d885184a1dcf06d16e28c6eaf1764748a28" }, "downloads": -1, "filename": "b2blaze-0.1.9.tar.gz", "has_sig": false, "md5_digest": "05063a270758f5bcb2b8713a29a2d0db", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7", "size": 12688, "upload_time": "2018-08-02T21:44:30", "url": "https://files.pythonhosted.org/packages/2e/91/fcd57fa2cd5356c8c536374c1c8e18bd7f195591a12f00e0be629e571574/b2blaze-0.1.9.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "6a8d8fa34807ca07fe0d7fee5b715b27", "sha256": "4cc7ac626ca3aed548ac4b4e893fc83ffd013fa4c134717c217c5174c9171d41" }, "downloads": -1, "filename": "b2blaze-0.2.1-py3-none-any.whl", "has_sig": false, "md5_digest": "6a8d8fa34807ca07fe0d7fee5b715b27", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=2.7", "size": 18132, "upload_time": "2018-11-02T18:22:40", "url": "https://files.pythonhosted.org/packages/ed/23/8c1550df00840188e25c37a70de974aba99104ad4607913c862879c2783e/b2blaze-0.2.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e4c555ae41215c1bc1e1bb29f339e37d", "sha256": "b105ddf55209fff520d418d623fc719ed826f58e53cc28eb7ba1becd9bb06a44" }, "downloads": -1, "filename": "b2blaze-0.2.1.tar.gz", "has_sig": false, "md5_digest": "e4c555ae41215c1bc1e1bb29f339e37d", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7", "size": 16327, "upload_time": "2018-11-02T18:22:42", "url": "https://files.pythonhosted.org/packages/a8/7d/d1657085f9b872e304e2c0407095680a482e04d7301bc17a06d314e6fe8d/b2blaze-0.2.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "6a8d8fa34807ca07fe0d7fee5b715b27", "sha256": "4cc7ac626ca3aed548ac4b4e893fc83ffd013fa4c134717c217c5174c9171d41" }, "downloads": -1, "filename": "b2blaze-0.2.1-py3-none-any.whl", "has_sig": false, "md5_digest": "6a8d8fa34807ca07fe0d7fee5b715b27", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=2.7", "size": 18132, "upload_time": "2018-11-02T18:22:40", "url": "https://files.pythonhosted.org/packages/ed/23/8c1550df00840188e25c37a70de974aba99104ad4607913c862879c2783e/b2blaze-0.2.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e4c555ae41215c1bc1e1bb29f339e37d", "sha256": "b105ddf55209fff520d418d623fc719ed826f58e53cc28eb7ba1becd9bb06a44" }, "downloads": -1, "filename": "b2blaze-0.2.1.tar.gz", "has_sig": false, "md5_digest": "e4c555ae41215c1bc1e1bb29f339e37d", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7", "size": 16327, "upload_time": "2018-11-02T18:22:42", "url": "https://files.pythonhosted.org/packages/a8/7d/d1657085f9b872e304e2c0407095680a482e04d7301bc17a06d314e6fe8d/b2blaze-0.2.1.tar.gz" } ] }