Skip to content

Commit 51a596f

Browse files
committed
Adde an example for sending attachments
1 parent 5edc341 commit 51a596f

File tree

5 files changed

+406
-5
lines changed

5 files changed

+406
-5
lines changed

examples/.env.example

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,7 @@ NYLAS_API_URI=https://api.us.nylas.com
1212

1313
# Grant ID - Required for message and event examples
1414
# You can get this from your Nylas Dashboard after connecting an account
15-
NYLAS_GRANT_ID=your_grant_id_here
15+
NYLAS_GRANT_ID=your_grant_id_here
16+
17+
# Test email
18+
NYLAS_TEST_EMAIL=your@email.com

examples/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ help:
1010
@echo " java-notetaker - Run the Java Notetaker example"
1111
@echo " java-events - Run the Java Events example"
1212
@echo " java-folders - Run the Java Folders example"
13+
@echo " java-large-attachments - Run the Java Large Attachments example"
1314
@echo " kotlin-notetaker - Run the Kotlin Notetaker example"
1415
@echo " kotlin-folders - Run the Kotlin Folders example"
1516

@@ -24,6 +25,9 @@ java-notetaker:
2425
java-messages:
2526
@cd .. && ./gradlew :examples:run -PmainClass=com.nylas.examples.MessagesExample
2627

28+
java-large-attachments:
29+
@cd .. && ./gradlew :examples:run -PmainClass=com.nylas.examples.LargeAttachmentsExample
30+
2731
java-events:
2832
@cd .. && ./gradlew :examples:run -PmainClass=com.nylas.examples.EventsExample
2933

examples/README.md

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,17 @@ The `FoldersExample` and `KotlinFoldersExample` demonstrate how to use the Nylas
4040
- Demonstrate the builder pattern with various query parameters
4141
- Show folder details including parent relationships and unread counts
4242

43+
### Large Attachments Example
44+
45+
The `LargeAttachmentsExample` demonstrates how to send emails with large file attachments using the Nylas Java SDK:
46+
47+
- Create and send emails with 3MB and 10MB test files
48+
- Demonstrate the SDK's automatic handling of large attachments (switches to multipart form data for files ≥ 3MB)
49+
- Send multiple large attachments in a single email
50+
- Compare small vs large attachment handling mechanisms
51+
- Use the `FileUtils.attachFileRequestBuilder()` helper method for easy file attachment
52+
- Automatic cleanup of temporary test files
53+
4354
## Setup
4455

4556
### 1. Environment Setup
@@ -58,6 +69,9 @@ NYLAS_API_KEY=your_api_key_here
5869
# Your grant ID (required for message examples)
5970
NYLAS_GRANT_ID=your_grant_id_here
6071
72+
# Test email address (required for large attachments example)
73+
NYLAS_TEST_EMAIL=test@example.com
74+
6175
# Add your meeting link (Zoom, Google Meet, or Microsoft Teams) - for Notetaker example
6276
MEETING_LINK=your_meeting_link_here
6377
```
@@ -101,6 +115,11 @@ Run Kotlin Folders example:
101115
./gradlew :examples:run -PmainClass=com.nylas.examples.KotlinFoldersExampleKt
102116
```
103117

118+
Run Java Large Attachments example:
119+
```bash
120+
./gradlew :examples:run -PmainClass=com.nylas.examples.LargeAttachmentsExample
121+
```
122+
104123
#### Option 2: Using the Makefile
105124

106125
List available examples:
@@ -127,6 +146,7 @@ make kotlin-way
127146
- `KotlinMessagesExample.kt` (Kotlin - demonstrates new message features)
128147
- `EventsExample.java` (Java - demonstrates events)
129148
- `FoldersExample.java` (Java - demonstrates folders and single_level parameter)
149+
- `LargeAttachmentsExample.java` (Java - demonstrates large file attachments)
130150
- `NotetakerExample.java` (Java - demonstrates notetakers)
131151
- `KotlinNotetakerExample.kt` (Kotlin - demonstrates notetakers)
132152
- `KotlinFoldersExample.kt` (Kotlin - demonstrates folders and single_level parameter)
@@ -143,10 +163,11 @@ examples/
143163
└── main/
144164
├── java/ # Java examples
145165
│ └── com/nylas/examples/
146-
│ ├── MessagesExample.java # NEW: Message features demo
147-
│ ├── EventsExample.java # Events API demo
148-
│ ├── FoldersExample.java # NEW: Folders API demo with single_level parameter
149-
│ └── NotetakerExample.java # Notetaker API demo
166+
│ ├── MessagesExample.java # NEW: Message features demo
167+
│ ├── EventsExample.java # Events API demo
168+
│ ├── FoldersExample.java # NEW: Folders API demo with single_level parameter
169+
│ ├── LargeAttachmentsExample.java # NEW: Large file attachments demo
170+
│ └── NotetakerExample.java # Notetaker API demo
150171
└── kotlin/ # Kotlin examples
151172
└── com/nylas/examples/
152173
├── KotlinMessagesExample.kt # NEW: Message features demo

examples/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ tasks.register("listExamples") {
5555
println("- Java-Events: com.nylas.examples.EventsExample")
5656
println("- Java-Messages: com.nylas.examples.MessagesExample")
5757
println("- Java-Folders: com.nylas.examples.FoldersExample")
58+
println("- Java-Large-Attachments: com.nylas.examples.LargeAttachmentsExample")
5859
println("- Kotlin-Notetaker: com.nylas.examples.KotlinNotetakerExampleKt")
5960
println("- Kotlin-Messages: com.nylas.examples.KotlinMessagesExampleKt")
6061
println("- Kotlin-Folders: com.nylas.examples.KotlinFoldersExampleKt")

0 commit comments

Comments
 (0)