Full completed project
This commit is contained in:
42
android-client/modules/handler/info.py
Normal file
42
android-client/modules/handler/info.py
Normal file
@@ -0,0 +1,42 @@
|
||||
from PIL import Image
|
||||
import io
|
||||
from android.storage import app_storage_path
|
||||
root_path = app_storage_path()
|
||||
|
||||
class profile():
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def username():
|
||||
pass
|
||||
|
||||
def name(self, first_name=None, last_name=None):
|
||||
if first_name:
|
||||
self.first_name
|
||||
if last_name:
|
||||
self.last_name
|
||||
|
||||
if first_name and last_name:
|
||||
pass
|
||||
|
||||
class image():
|
||||
def __init__(self, post_id):
|
||||
self.post_id = post_id
|
||||
self.path = None
|
||||
|
||||
def load(self, image_bytes):
|
||||
image_formats = ['png', 'jpg']
|
||||
for form in image_formats:
|
||||
try:
|
||||
self.path = root_path + f"data/images/{self.post_id}.{form}"
|
||||
with Image.open(io.BytesIO(image_bytes)) as recieved:
|
||||
recieved.save(self.path)
|
||||
print("saved image")
|
||||
break
|
||||
except:
|
||||
print("cant save image")
|
||||
self.path = None
|
||||
|
||||
def delete(self):
|
||||
os.remove(self.path)
|
||||
|
||||
Reference in New Issue
Block a user