MLH-Fellowship / orientation-project-python-24.FAL.A

Orientation Project (Python for 24.FAL.A)
0 stars 10 forks source link

Add Logo Upload Functionality for Experience, Education, and Skill Objects #30

Closed hastagAB closed 1 month ago

hastagAB commented 1 month ago

closes #2

Add functionality to upload and store logos for Experience, Education, and Skill objects in the uploads/ directory.

hastagAB commented 1 month ago

@Pradyuman7 Please review the PR

awilkescom commented 1 month ago

Looks good @hastagAB - can you resolve the conflict and we can merge?

hastagAB commented 1 month ago

@awilkescom Resolved. Please merge!

awilkescom commented 1 month ago

Great, good work!

larrytamnjong commented 1 month ago

Hi @hastagAB I'm trying to upload an image from the frontend to the backend, and while the form data seems to be coming through, I'm consistently receiving a 415 error from the /resume/experience endpoint. I've logged the payload from the frontend and attached a screenshot. Could you take a look and let me know if you have any insights on this?

image

hastagAB commented 1 month ago

Hi @larrytamnjong, try with multipart/form-data in all cases. Make sure you're using FormData to submit your file and other fields.

fetch('/resume/experience', { method: 'POST', body: formData, }) .then(response => response.json()) .then(data => { console.log('Success:', data); }) .catch(error => { console.error('Error:', error); });

larrytamnjong commented 1 month ago

@hastagAB I am sending form data in all cases, and I realized the issue is with using request.get_json(). When I changed the function in the experience route to use request.form directly, it worked. The method request.get_json() throws a 415 error. You can read more about it here: Flask Request Documentation.

hastagAB commented 1 month ago

@larrytamnjong Ah okayy! I'm glad it worked.