bellhop-0.0.1
توضیحات
Classy solution for file uploads in Django. Inspired by CarrierWave.
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | bellhop-0.0.1 |
| نام | bellhop |
| نسخه کتابخانه | 0.0.1 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | - |
| ایمیل نویسنده | Shubham Sharma <sharshub@users.noreply.github.com> |
| آدرس صفحه اصلی | - |
| آدرس اینترنتی | https://pypi.org/project/bellhop/ |
| مجوز | - |
# BellHop
BellHop is a simple way to upload files from Django applications. It is inspired by the [CarrierWave](https://github.com/carrierwaveuploader/carrierwave) gem for Ruby. Currently, only AWS is supported.
## Installation
Install from PyPI
```shell
pip install bellhop
```
Once done, add the `BELLHOP` settings in your `settings.py` file:
```python
BELLHOP = {
"STORAGE": "aws",
"AWS_ACCESS_KEY_ID": os.environ["AWS_ACCESS_KEY_ID"],
"AWS_SECRET_ACCESS_KEY": os.environ["AWS_SECRET_ACCESS_KEY"],
"S3_BUCKET": os.environ["S3_BUCKET"],
"S3_REGION": os.environ["S3_REGION"],
}
```
## Example
Define a model in `models.py` which would store a file. The model should contain one `CharField` which we would use to reference the file.
In this example, the file would be stored using the field `file` of model `Document`.
```python
class Document(models.Model):
file = models.CharField(max_length=255)
```
Create a file `uploaders.py` in your app. We would register the model with an uploader, where we define the field which references the file as `uploadable`, which is `file` in our case:
```python
from testapp.models import Document
from bellhop import bellhop, BaseUploader
class DocumentUploader(BaseUploader):
uploadable = "file"
bellhop.register(Document, DocumentUploader)
```
Now, you can easily upload a file as:
```python
file = open('/path/to/file')
document = Document.objects.create(file=file)
# Access the url of the file
document.file_url
```
نیازمندی
| مقدار | نام |
|---|---|
| - | boto3>=1.26 |
| - | django>=3.2 |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.7 | Python |
نحوه نصب
نصب پکیج whl bellhop-0.0.1:
pip install bellhop-0.0.1.whl
نصب پکیج tar.gz bellhop-0.0.1:
pip install bellhop-0.0.1.tar.gz