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

Add example for sending media #231

Open
nikoksr opened this issue Jul 17, 2023 · 3 comments
Open

Add example for sending media #231

nikoksr opened this issue Jul 17, 2023 · 3 comments
Labels
card format/adaptivecard Adaptive Card support help wanted Extra attention is needed question Further information is requested

Comments

@nikoksr
Copy link

nikoksr commented Jul 17, 2023

Hi, notify author here. We're currently working on a v2 and I'm interested in uploading/sending files in the form of a message attachment to Teams.

I've worked my way through the code and I see things like the attachment type, image elements and media elements. Using, for example, an image element and adding it as a card to an existing adaptive card, seems straight forward. However, it expects an URL, implying that the image has to have been uploaded somewhere before. The functionality we're aiming for and that most other services (so far) support, is uploading a local file as a message attachment. Is there a way to do this, that I'm overlooking?

Secondly, is there a way to upload non-image type files? Most other platforms support a way to upload a file of arbitrary type. I'd assume that this is done via the media type but the comment suggests, that this may not be functional with Teams. I'd appreciate if you could clarify this for me.

@atc0005 atc0005 added question Further information is requested card format/adaptivecard Adaptive Card support labels Jul 17, 2023
@atc0005
Copy link
Owner

atc0005 commented Jul 17, 2023

Hi @nikoksr,

Some references that I used for those types:

From what I could tell the expectation is (as you noted) that the content be uploaded somewhere else and then referenced as a URL.

If you learn differently please share as that could benefit others also.

@atc0005 atc0005 added the help wanted Extra attention is needed label Jul 21, 2023
@nikoksr
Copy link
Author

nikoksr commented Aug 3, 2023

Hi @atc0005,

Thanks for providing the references. Based on my understanding, it seems that the current expectation for content in the library is to upload it somewhere else and then reference it as a URL. However, I come from a background where I'm used to providing attachments as a byte slice or io.Reader to the respective send logic in other services.

For instance, in the Slack service, I can pass a reader that streams the local file into the upload parameters, as shown in this example:

params := slack.UploadFileV2Parameters{
	Channel:  channelID,
	Reader:   attachment.Reader(),
	Filename: attachment.Name(),
	FileSize: int(attachment.Size()),
	AltTxt:   attachment.Name(),
}

if _, err := s.client.UploadFileV2Context(ctx, params); err != nil {
	return err
}

All other services that support file uploads have similar functionality.

Just to be clear, not pointing fingers at your library here at all; It seems that this issue is related to the API rather than your library. I'm simply looking for clarification to ensure that my understanding is correct. Thank you for your help!

@atc0005
Copy link
Owner

atc0005 commented Aug 3, 2023

@nikoksr: Just to be clear, not pointing fingers at your library here at all

Oh, I don't take offense. There is a lot to be improved here. Feedback is welcome.

It seems that this issue is related to the API

That is my understanding as well. I've not worked with attachments myself, only stubbed out what support there currently is for them (going from memory it probably isn't much).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
card format/adaptivecard Adaptive Card support help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants