guess_filename(obj) doesn't recognize werkzeug.datastructures.FileStorage

This is my _first_ issue ever on any repo. So kindly forgive me if I'm asking a naive question or don't have enough information provided.

I am currently working on an API in **Flask-Restful** on Client side and also have to consume the Server side API using **Requests** API.
- So I was adding an image along with some other form components like text and sending it to the Server side API using Requests' POST call.
- The datastructure understood by Flask-restful for Images/ Files is werkzeug.datastructures.FileStorage, which I think is similar to a Multi-dict.

``` Python
def post():
    payload_data = {}   # some data
    payload_files = {}   # abc.png
    url = http://xyz/api/
    response_obj = requests.post(url, data=payload_data, files=payload_file)
```
- Now inside the **models.py**, at line https://github.com/kennethreitz/requests/blob/master/requests/models.py#L117 gives me the value for **files** as 

``` python
[('form_image', <FileStorage: 'abc.png' ('image/png')>)]
# form_image is just the name of the image in form.

```

The key-value structure of a normal FileStorage object is something like this (from debugger)

```
* {FileStorage} <FileStorage: 'abc.png' ('image/png')>
     * _parsed_content_type = {tuple} ('image/png', {})
     * content_length = {int} 0
     * content_type = {str} 'image/png'
     * filename = {str} 'abc.png'
     * headers = {Headers} Content-Disposition: form-data; name="form_image";
     * filename="abc.png"\r\nContent-Type: image/png\r\n\r\n
     * mimetype = {str} 'image/png'
     * mimetype_params = {dict} {}
     * name = {str} 'form_image'
     * stream = {BufferedRandom} <_io.BufferedRandom name=9>
```

Note that the filename is inside the key `filename` and not `name`.

Then it calls the guess_filename at 

``` python
fn = guess_filename(v) or k
```

In the guess_filename(obj), the value of the obj is still 

``` python
<FileStorage: 'abc.png' ('image/png')>
```

**THIS LINE** checks the object and checks the key "name" instead of **"filename"**

``` python
name = getattr(obj, 'name', None)
```
- After this, the value of `name` is now **"form_image"** _instead of_ **"abc.png"**
- As a result, the server side receives the file with the name `form_image`, instead of the real file name.
- Is there a solution to this? Please let me know.
- If not, it seems that `FileStorage` works differently than was anticipated in `guess_filename`. So does there have to be some line that does this:

``` python
from werkzeug import datastructures
if isinstance(obj, FileStorage):
    name = getattr(obj, 'filename', None)
else:
    name = getattr(obj, 'name', None)
```


> This is my first issue ever on any repo. So kindly forgive me if I'm asking a naive question or don't have enough information provided.

Welcome! Thanks for getting started with us! :tada: :cake: :balloon: 

So to your core question, the `guess_filename` function is a bit tricky. It basically does its best to handle things that might reasonably be passed in that come from the standard library. Sadly, writing special-case code to handle all non-stdlib objects is probably outside the scope of this library.

The "correct" way to do this is to use the extended form of the `files` parameter. Rather than pass just the `FileStorage` object as the value of the dict, try passing a tuple of the form `(payload_file.filename, payload_file)`. The first element will be used as the filename, overriding the choice of `guess_filename`. That's what you should use whenever our choice is bad.


Oh yeah. I should have read [this](http://www.python-requests.org/en/latest/api/#main-interface) properly. It solved the **filename** problem. :+1:  Thank you so much.

Although, it opened up a problem incomprehensible to me,

While feeding the file from Client-side API to Server-side API through `Requests`, the `content-type` gets set to `None`.

Edit: **Not only that, the file itself is None (= empty). Why is that?**
- This is when I POST to the `Requests` API, inside the `sessions.py`, the value of `files` is this:

<img width="892" alt="before_req" src="https://cloud.githubusercontent.com/assets/10097486/9141625/1f96a104-3d08-11e5-88b9-5e940fb484e7.png">
- But, when it comes out of it (I tried really hard to debug, but didn't understand what's happening behind the scenes), this is the format of `files` in the entry point of Server-side API.

<img width="695" alt="after_req" src="https://cloud.githubusercontent.com/assets/10097486/9141634/30df18ce-3d08-11e5-98ad-9e932518bdc4.png">
- Do you think I am doing something wrong here? Can you suggest something?
- Also, why can't I do this:

``` Python
def post():
    payload_json = {}   # data in json format
    payload_files = {}   # abc.png
    url = http://xyz/api/
    response_obj = requests.post(url, json=payload_data, files=payload_file)
```

(If I do this, the `files` data gets sent and the `json` and `data` header are `None`.)

Instead of this:

``` Python
def post():
    payload_data = {}   # some data
    payload_files = {}   # abc.png
    url = http://xyz/api/
    response_obj = requests.post(url, data=payload_data, files=payload_file)
```


Probably the server side takes the content type from a specific header. Try using the even more extended form of the `files` parameter, by passing a tuple of the form `(payload_file.filename, payload_file, payload_file.content_type)`.

As to why you can't use JSON with files, the main reason is that it's not clear how the JSON will fit into the multipart upload. It's generally better to let users do this themselves,as we will just get it wrong.