question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Docs: Add example for parsing files

See original GitHub issue

Hey guys,

I’ve been consulting the documentation and the web for a proper solution to parse file arguments from a post request using webargs, but still couldn’t find an answer to my question.

The docs says you can use the files location during parsing but mentions no straightforward solution on which field to use for files?

Can you include an example in the docs for this one, if it’s possible to do at all?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
sloriacommented, Jun 7, 2018

If you use fields.Field, marshmallow won’t do any processing on the value, so you’ll get a framework-specific file wrapper object. For example, you’ll get a FileStorage object in Flask.

0reactions
johnny-cycommented, Jul 24, 2021

It seems not working for me, postman upload through body->form-data->choose a zip file and put ‘file’ in its key, it still gave me 422 when I set required=True, don’t know why, here is what I tried @use_kwargs({"file": fields.Field(validate=lambda file: "zip" == file.filename.split(".")[-1].lower(), location="files", required=True)}) and couldn’t find fields.Field validate on doc or anywhere, am I doing it correct ?

I found the problem I put location in wrong place, it should be put as second arg of use_kwargs: @use_kwargs({"file": fields.Field(validate=lambda file: "zip" == file.filename.split(".")[-1].lower(), required=True)}, location="files")

Read more comments on GitHub >

github_iconTop Results From Across the Web

ParseFile - Documentation
A Parse.File is a local representation of a file that is saved to the Parse cloud ... 4. a File object selected with...
Read more >
Use Markdown in Google Docs, Slides, & Drawings
You can use Markdown to quickly add formatting elements to your Google Docs, Slides, and Drawings. With Markdown, you can format text to...
Read more >
Build an interface to parse text from any type of document
In this example, we're calling the parse method in a loop with paths to txt, docx, pdf, html, and pptx files, and printing...
Read more >
Extract the text from a document | Google Docs
The following sample uses recursion to visit each structural element in a document and prints the text. You'll need to have a project...
Read more >
Send a processing request | Document AI
Batch processing. Batch (asynchronous) requests let you send multiple documents in a single request. Document AI responds with an operation that you ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found