North-Seattle-College / ad440-winter2020-tuesday-repo

Repository for AD 440 Winter 2020 Tuesday Class
Apache License 2.0
2 stars 3 forks source link

API to upload image to Azure Storage POST https://api.1edusite.com/images #257

Closed jerwest closed 4 years ago

leitto10 commented 4 years ago

I estimate that this task will take me about 20 hours to complete.

leitto10 commented 4 years ago

Created a connection string to blob storage hard coded credential at the moment. and I get the following error Result: Failure Exception: ModuleNotFoundError: No module named 'azure.storage' Stack: File "/azure-functions-host/workers/python/3.7/LINUX/X64/azure_functions_worker/dispatcher.py", line 242, in _handlefunction_load_request func_request.metadata.entry_point) File "/azure-functions-host/workers/python/3.7/LINUX/X64/azure_functions_worker/loader.py", line 66, in load_function mod = importlib.import_module(fullmodname) File "/usr/local/lib/python3.7/importlib/init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "/home/site/wwwroot/uploadImage/init__.py", line 4, in from azure.storage.blob import BlockBlobService, BlobPermissions

5 hours trouble shooting.

leitto10 commented 4 years ago

keep getting a different error Result: Failure Exception: AttributeError: 'dict' object has no attribute 'encode' Stack: File "/azure-functions-host/workers/python/3.7/LINUX/X64/azure_functions_worker/dispatcher.py", line 315, in _handleinvocation_request self.__run_sync_func, invocation_id, fi.func, args) File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/azure-functions-host/workers/python/3.7/LINUX/X64/azure_functions_worker/dispatcher.py", line 434, in run_sync_func return func(**params) File "/home/site/wwwroot/uploadImage/init.py", line 33, in main base64_img_bytes = req_body.encode('utf-8') so I had to turn the json body to a string so I can decode to binary

leitto10 commented 4 years ago

took me about 25 hours to complete the task since I had to spend more time troubleshooting than codding. I was making a few mistakes in my code that make me realize I need to review my data structures.

Pull request # https://github.com/North-Seattle-College/ad440-winter2020-tuesday-repo/pull/357

Task to test: https://github.com/North-Seattle-College/ad440-winter2020-tuesday-repo/issues/263

WikiPage: https://github.com/North-Seattle-College/ad440-winter2020-tuesday-repo/wiki/API-to-upload-image-to-Azure-Storage-POST