# Single file upload in apollo gateway

**URL:** <https://community.apollographql.com/t/single-file-upload-in-apollo-gateway/6421>\
**Category:** Server\
**Tags:** server, federation\
**Created:** [June 29, 2023, 10:06am UTC](https://community.apollographql.com/t/single-file-upload-in-apollo-gateway/6421 "2023-06-29T10:06:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Priya\_Nithi](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/priya_nithi/32/4394_2.png) [@Priya\_Nithi](https://community.apollographql.com/u/Priya_Nithi)\
**Post date:** [June 29, 2023, 10:06am UTC](https://community.apollographql.com/t/single-file-upload-in-apollo-gateway/6421/1 "2023-06-29T10:06:58Z")

</div>

Hi,  
I’m trying to upload a file to springboot microservice  
In the client side am using apollo-upload -client package to send file from client to apollo server.  
In apollo server , using @profusion/apollo-federation-upload package to enable file uploads.  
I’m attaching my code to run apollo server here

const { ApolloServer } = require(‘apollo-server’);  
const { ApolloGateway} = require(‘@apollo/gateway’);  
const { readFileSync } = require(‘fs’);  
const FileUploadDataSource = require(‘@profusion/apollo-federation-upload/build/FileUploadDataSource.js’);

const supergraphSdl = readFileSync(‘supergraph.graphql’).toString();

class AuthenticatedDataSource extends FileUploadDataSource{  
willSendRequest({request,context}) {  
request.http.headers.set(“bearer”, context.token);  
request.http.headers.set(“role”, context.role);  
}  
}

const gateway = new ApolloGateway({  
supergraphSdl, buildService : ({url}) =\> new AuthenticatedDataSource({url})  
});

const server = new ApolloServer({  
gateway,  
context: ({req}) =\> {  
const token = req.headers.bearer || ‘’;  
const role = req.headers.role || ‘’;  
return { token , role}  
},  
subscriptions: false  
});

server.listen().then(({ url }) =\> {  
console.log(`🚀Server ready at ${url}`)  
});

While running this code ,I always getting this below error

 ![image](https://us1.discourse-cdn.com/flex019/uploads/apollographql/original/2X/2/2126ecdeae3d209df9004fe74de7ff33c8e2144c.png)

Am adding the versions of each package also here  
“@apollo/gateway”: “^2.4.1”,  
“@profusion/apollo-federation-upload”: “^4.0.0”,  
“apollo-server”: “^3.12.0”,  
“fs”: “^0.0.1-security”,  
“graphql”: “^16.6.0”

Error is in extending FileUploadDataSource class , can anyone please help me to resolve this error 🙂

---

<div class="post-metadata">

**Author:** ![Justin\_Gonzalez](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/justin_gonzalez/32/5359_2.png) [@Justin\_Gonzalez](https://community.apollographql.com/u/Justin_Gonzalez)\
**Post date:** [February 6, 2025, 8:48pm UTC](https://community.apollographql.com/t/single-file-upload-in-apollo-gateway/6421/2 "2025-02-06T20:48:40Z")

</div>


