# Send and read file in RayServe

**URL:** <https://discuss.ray.io/t/send-and-read-file-in-rayserve/7891>\
**Category:** Uncategorized\
**Created:** [October 13, 2022, 12:57pm UTC](https://discuss.ray.io/t/send-and-read-file-in-rayserve/7891 "2022-10-13T12:57:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bocharova.maiia](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/bocharova.maiia/32/3311_2.png) [@bocharova.maiia](https://discuss.ray.io/u/bocharova.maiia)\
**Post date:** [October 13, 2022, 12:57pm UTC](https://discuss.ray.io/t/send-and-read-file-in-rayserve/7891/1 "2022-10-13T12:57:00Z")

</div>

Hello, I am trying to use my existing fastapi code, but scale it with RayServe. This is the code snippet:

```auto
from fastapi import UploadFile, FastAPI
from ray import serve
app = FastAPI()

@serve.deployment() 
@serve.ingress(app)
class MyFastAPIDeployment:
    @app.post("/segment_text")
    async def segment_text(text: UploadFile):
        text = await text.read()

```

This code in FastApi worked fine, but with RayServe I am getting an error `'MyFastAPIDeployment' object has no attribute 'read'`  
Can you please advice me on how to send files and read them?

---

<div class="post-metadata">

**Author:** ![bocharova.maiia](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/bocharova.maiia/32/3311_2.png) [@bocharova.maiia](https://discuss.ray.io/u/bocharova.maiia)\
**Post date:** [October 14, 2022, 10:06am UTC](https://discuss.ray.io/t/send-and-read-file-in-rayserve/7891/2 "2022-10-14T10:06:03Z")

</div>

Mistake found - forgot about `self`. Should be

```auto
from fastapi import UploadFile, FastAPI
from ray import serve
app = FastAPI()

@serve.deployment() 
@serve.ingress(app)
class MyFastAPIDeployment:
    @app.post("/segment_text")
    async def segment_text(self, text: UploadFile):
        text = await text.read()

```

---

<div class="post-metadata">

**Author:** ![shrekris](https://avatars.discourse-cdn.com/v4/letter/s/ce73a5/32.png) [@shrekris](https://discuss.ray.io/u/shrekris)\
**Post date:** [October 18, 2022, 8:08pm UTC](https://discuss.ray.io/t/send-and-read-file-in-rayserve/7891/3 "2022-10-18T20:08:54Z")

</div>

Thanks for following up with your solution @bocharova.maiia! You can also post questions about Ray Serve in the [Ray Serve channel](https://discuss.ray.io/c/ray-air/ray-serve) where more Ray Serve users can help out.
