Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support passing tuple through bytes type that are meant for multipart form-data #2378

Closed
lmazuel opened this issue Jan 22, 2024 · 1 comment · Fixed by #2380
Closed

Support passing tuple through bytes type that are meant for multipart form-data #2378

lmazuel opened this issue Jan 22, 2024 · 1 comment · Fixed by #2380
Assignees
Labels
blocking service feature-request This issue requires a new behavior in the product in order be resolved. p0

Comments

@lmazuel
Copy link
Member

lmazuel commented Jan 22, 2024

Assuming this TypeSpec:

op uploadImage(@header contentType: "multipart/form-data", @body image: MultiPartRequest): void;

model MultiPartRequest {
  profileImage: bytes;  // This is a file. Implies filename and content-type.

  pictures: bytes[]; // This is as many part as necessary. Implies filename and content-type.
  
}

We should be able to pass tuple syntax, as supported by azure-ccore in Azure/azure-sdk-for-python#32566

For instance:

client.uploadImage(
  MultiPartRequest(
    profileImage=open("profile.jpg"),
    pictures=[
      open("pic1.jpg"), # Only the bytes
      ("specialpic.gif", open("pic4.gif")), # Bytes and filename
      ("coolpic.tiff", open("pic3.tiff"), "application/tiff"), # Bytes, filename and content-type
    ]
  )    
)

I would expect codegen just pass through the data directly to azure-core, I see not reason why codegen would update the tuple.

@lmazuel lmazuel added feature-request This issue requires a new behavior in the product in order be resolved. p0 labels Jan 22, 2024
@iscai-msft
Copy link
Contributor

Related core pr: Azure/azure-sdk-for-python#33948

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocking service feature-request This issue requires a new behavior in the product in order be resolved. p0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants