> For the complete documentation index, see [llms.txt](https://painor.gitbook.io/gramjs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://painor.gitbook.io/gramjs/getting-started/available-methods/uploading-files-1.md).

# Uploading files

## Using `SendFile`

Uploading files can be tricky since GramJS needs to support both browsers and nodeJS. \
You can use the `sendFile` methods for most use cases

```typescript
await client.sendFile("me",{
    file: "video.mp4",
});
```

## Using `UploadFile`

If you need more control over the upload process you can use `uploadFile` which returns an InputFile that you can add attributes to and use in other methods such as changing profile picture.

when using uploadFile you'll need to specify the size and name yourself using the `CustomFile` class

```typescript
const toUpload = new CustomFile("photo.jpg", fs.statSync("../photo.jpg").size, "../photo.jpg");
const file = await client.uploadFile({
   file: toUpload,
   workers: 1,
 });
await client.invoke(new Api.photos.UploadProfilePhoto({
    file: file,
}));
```

## Increasing speed

If you want to upload at a faster rate GramJS provides an attribute called workers. by default, it's 1 which means a stable and slow upload. increasing this will improve upload speed but might make it unstable.

**Note:** Using anything above 15 is discouraged because telegram will disconnect you.

```typescript
const toUpload = new CustomFile("bigFile.zip", fs.statSync("../bigFile.zip").size, "../bigFile.zip");
const file = await client.uploadFile({
   file: toUpload,
   workers: 10,
 });
```

&#x20;&#x20;


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://painor.gitbook.io/gramjs/getting-started/available-methods/uploading-files-1.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
