new identifier and added creation folder logic
This commit is contained in:
parent
e1a1cb25fc
commit
2e58c64ced
@ -54,7 +54,12 @@ def get_image(identifier):
|
||||
b64encoded_image = unwrap_file(payload['image_data'])
|
||||
goal_folder_name = "images_fetch"
|
||||
path = "../../"+goal_folder_name+"/"+payload['metadata']['filename']
|
||||
|
||||
goal_folder_path = os.path.sep.join(os.path.abspath(__file__).split(os.path.sep)[:-3]) + os.path.sep + goal_folder_name
|
||||
|
||||
if not os.path.isdir(goal_folder_path):
|
||||
os.mkdir(goal_folder_path)
|
||||
|
||||
out = open(path, 'wb')
|
||||
out.write(b64encoded_image)
|
||||
out.close()
|
||||
|
||||
@ -16,5 +16,7 @@ class MongoManager:
|
||||
MongoManager.__instance = pymongo.MongoClient('127.0.0.1', 27017)
|
||||
db = MongoManager.__instance.AIC
|
||||
coll = db.metadata
|
||||
coll.create_index("filename",unique=True)
|
||||
coll.create_index([("loc", pymongo.GEO2D)])
|
||||
db.coll["identifier"]
|
||||
db.coll["location"]
|
||||
coll.create_index("identifier",unique=True)
|
||||
coll.create_index([("location", pymongo.GEO2D)])
|
||||
@ -55,7 +55,7 @@ class ImageEndpoint:
|
||||
col = db.metadata
|
||||
metadata = None
|
||||
try:
|
||||
resp = col.find({"filename": identifier+".jpg"})
|
||||
resp = col.find({"identifier": identifier})
|
||||
metadata = resp[0]
|
||||
except:
|
||||
print("Could not find Metadata")
|
||||
@ -94,6 +94,7 @@ class ImageEndpoint:
|
||||
col = db.metadata
|
||||
|
||||
try:
|
||||
metadata['identifier'] = identifier
|
||||
metadata['location'] = [metadata['longitude'],metadata['latitude']]
|
||||
col.insert_one(metadata)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user