first push

This commit is contained in:
2026-01-18 12:05:56 +03:30
commit cdbb2e11ed
109 changed files with 3083 additions and 0 deletions

View File

Binary file not shown.

View File

@@ -0,0 +1,60 @@
import io
import boto3
import logging
from PIL import Image
from botocore.exceptions import ClientError
from django.http import HttpResponse
import base64
# ARVAN_STORAGE_URL = "https://dmstore.s3.ir-thr-at1.arvanstorage.com/36bba98f-a813-4667-bd60-33aef708bcba.jpg?AWSAccessKeyId=d5739a44-e663-4f43-99f3-13121a62a9e6&Signature=KpBpHBtAS77Y3hHx53g6bmjlGpc%3D&Expires=1651552380"
def connect():
logging.basicConfig(level=logging.INFO)
try:
s3_resource = boto3.resource(
's3',
endpoint_url='https://s3.ir-thr-at1.arvanstorage.com',
aws_access_key_id='d5739a44-e663-4f43-99f3-13121a62a9e6',
aws_secret_access_key='bcc8bc64cac2de7711f8c5d3a4b0123f28319f97fb9e0e9b8fbcfd7465678cdb'
)
except Exception as exc:
logging.info(exc)
return s3_resource
def get_bucket_list():
s3_resource = connect()
li = []
try:
for bucket in s3_resource.buckets.all():
logging.info(f'bucket_name: {bucket.name}')
li.append(bucket.name)
except ClientError as exc:
logging.error(exc)
return li[0]
def upload_object(image_data, bucket_name, object_name):
resource_connect = connect()
s3_resource = resource_connect
bucket = s3_resource.Bucket(bucket_name)
buffer = io.BytesIO()
imgdata = base64.b64decode(image_data)
img = Image.open(io.BytesIO(imgdata))
new_img = img.resize((500, 500)) # x, y
new_img.save(buffer, format="PNG")
img_b64 = base64.b64encode(buffer.getvalue())
with open(object_name, "wb") as fh:
fh.write(base64.standard_b64decode(img_b64))
# base64.standard_b64decode(image_data)
with open(object_name, "rb") as fh:
bucket.put_object(
ACL='public-read',
Body=fh,
Key=object_name
)

0
Core/__init__.py Normal file
View File

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

3
Core/admin.py Normal file
View File

@@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

6
Core/apps.py Normal file
View File

@@ -0,0 +1,6 @@
from django.apps import AppConfig
class CoreConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'Core'

View File

Binary file not shown.

33
Core/models.py Normal file
View File

@@ -0,0 +1,33 @@
from django.db import models
from django.contrib.auth.models import User, Group
from django.conf import settings
from datetime import datetime, timezone, time
from django.utils import timezone
import uuid
# Create your views here.
class BaseModel(models.Model):
key = models.UUIDField(default=uuid.uuid4, editable=False, null=True, unique=True)
create_date = models.DateTimeField(auto_now_add=True)
modify_date = models.DateTimeField(auto_now=True)
created_by = models.ForeignKey(
settings.AUTH_USER_MODEL,
related_name="%(class)s_createdby",
on_delete=models.CASCADE,
null=True,
blank=True,
)
modified_by = models.ForeignKey(
settings.AUTH_USER_MODEL,
on_delete=models.CASCADE,
related_name="%(class)s_modifiedby",
null=True,
blank=True,
)
trash = models.BooleanField(default=False)
class Meta:
abstract = True

3
Core/tests.py Normal file
View File

@@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

1
Core/views.py Normal file
View File

@@ -0,0 +1 @@
from django.shortcuts import render