Skip to content

Rust SDK: Generate File Upload Methods for Binary/Bytes Request Body Endpoints #8456

@iamnamananand996

Description

@iamnamananand996

Which Fern component?

SDK Generator

How important is this?

P0 - Critical (Blocking work)

What's the feature?

Description:

Generate file upload methods for endpoints that accept bytes request bodies to enable proper binary file handling.

Current State:

  • Other generators support file upload methods with binary data parameters
  • Rust generates regular methods that don't handle bytes properly
  • HTTP client exists but file upload methods not generated

Problem:

When IR endpoint has requestBody.type === "bytes", current generator creates:

// Current (incorrect)
pub async fn upload_avatar(&self, request: &SomeType, options: Option<RequestOptions>) -> Result<User, ApiError>

Expected Implementation:

When requestBody.type === "bytes", generate:

// New (correct)
pub async fn upload_avatar(
    &self, 
    file_data: Vec<u8>, 
    options: Option<RequestOptions>
) -> Result<User, ApiError> {
    self.http_client.execute_request(
        Method::POST,
        "/users/avatar",
        Some(RequestBody::Bytes(file_data)), // New request body type
        options,
    ).await
}

// For endpoints with both bytes and metadata
pub async fn upload_document(
    &self,
    file_data: Vec<u8>,
    metadata: DocumentMetadata,
    options: Option<RequestOptions>
) -> Result<Document, ApiError> {
    // Multipart implementation
}

Acceptance Criteria:

  • Methods with bytes request body generate file upload signatures
  • Generated methods accept Vec<u8> for file data
  • HTTP client properly handles bytes request body
  • Multipart requests work for complex file uploads
  • Integration test uploads actual file successfully
  • Error handling works for file upload failures

Definition of Done:

  • File upload methods generated for all bytes endpoints
  • Methods accept Vec<u8> parameter for file data
  • HTTP requests properly send binary data
  • Integration tests demonstrate successful file uploads
  • Error handling covers file upload edge cases

Any alternatives?

No response

Are you interested in contributing this feature?

Yes

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions