// ChatAttachmentUploadStart implements the chat1.NotifyChatInterface
// for ChatRPC.
1823
func (c *ChatRPC) ChatAttachmentUploadStart(
	_ context.Context, _ chat1.ChatAttachmentUploadStartArg) error {
	return nil
}
1034564
func (c *ChatRPC) ChatSetTeamRetention(
	_ context.Context, _ chat1.ChatSetTeamRetentionArg) error {
	return nil
}
209114
func (c *ChatRPC) ChatPaymentInfo(
	_ context.Context, _ chat1.ChatPaymentInfoArg) error {
	return nil
}
1189531
func (rtm *Client) ChatPostMessage(m *ChatMessage) (*ChatMessageResponse, error) { //the response version of the message is returned for verification
	res := ChatMessageResponse{}
	err := NewExternalRequest().
		AsPost().
		WithScheme(APIScheme).
		WithHost(APIEndpoint).
		WithPath("api/chat.postMessage").
		WithPostData("token", rtm.Token).
		WithPostDataFromObject(m).
		JSON(&res)

	if err != nil {
		return nil, err
	}

	if !IsEmpty(res.Error) {
		return nil, exception.New(res.Error)
	}

	if !res.OK {
		return nil, exception.New("slack response `ok` is false.")
	}

	return &res, nil
}
741141
func createStage1AttachFlags(attachMode string) ([]string, error) {
	attachArgs := []string{}

	// list mode: just print endpoints
	if attachMode == "list" {
		attachArgs = append(attachArgs, "--action=list")
		return attachArgs, nil
	}

	// auto-attach mode: stage1-attach will figure out endpoints
	if attachMode == "auto" || attachMode == "" {
		attachArgs = append(attachArgs, "--action=auto-attach")
		return attachArgs, nil
	}

	// custom-attach mode: user specified endpoints
	var customEndpoints struct {
		TTYIn  bool
		TTYOut bool
		Stdin  bool
		Stdout bool
		Stderr bool
	}
	attachArgs = append(attachArgs, "--action=custom-attach")

	// parse comma-separated endpoints for custom attach
	eps := strings.Split(attachMode, ",")
	for _, e := range eps {
		switch e {
		case "stdin":
			customEndpoints.Stdin = true
		case "stdout":
			customEndpoints.Stdout = true
		case "stderr":
			customEndpoints.Stderr = true
		case "tty":
			customEndpoints.TTYIn = true
			customEndpoints.TTYOut = true
		case "tty-in":
			customEndpoints.TTYIn = true
		case "tty-out":
			customEndpoints.TTYOut = true
		default:
			return nil, fmt.Errorf("unknown endpoint %q", e)
		}
	}

	// check that the resulting attach mode is sane
	if !(customEndpoints.TTYIn || customEndpoints.TTYOut || customEndpoints.Stdin || customEndpoints.Stdout || customEndpoints.Stderr) {
		return nil, fmt.Errorf("mode must specify at least one endpoint to attach")
	}
	if (customEndpoints.TTYIn || customEndpoints.TTYOut) && (customEndpoints.Stdin || customEndpoints.Stdout || customEndpoints.Stderr) {
		return nil, fmt.Errorf("incompatible endpoints %q, cannot simultaneously attach TTY and streams", attachMode)
	}

	attachArgs = append(attachArgs,
		fmt.Sprintf("--tty-in=%t", customEndpoints.TTYIn),
		fmt.Sprintf("--tty-out=%t", customEndpoints.TTYOut),
		fmt.Sprintf("--stdin=%t", customEndpoints.Stdin),
		fmt.Sprintf("--stdout=%t", customEndpoints.Stdout),
		fmt.Sprintf("--stderr=%t", customEndpoints.Stderr),
	)
	return attachArgs, nil

}
933401
func NewPartAttachmentFromBytes(raw []byte, filename string) *Message {
	return newPartFromBytes(raw, mime.TypeByExtension(filepath.Ext(filename)), "attachment; filename=\""+filename+"\"", "")
}
1351171
func (c *ChatUpdateCall) Attachment(attachment *objects.Attachment) *ChatUpdateCall {
	c.attachments.Append(attachment)
	return c
}
409152
func (m *Message) NewAttachment() *Attachment {
	a := &Attachment{}
	m.AddAttachment(a)

	return a
}
712320
func (c *ChatUpdateCall) SetAttachments(attachments objects.AttachmentList) *ChatUpdateCall {
	c.attachments = attachments
	return c
}
716791
func (h *Server) DownloadAttachmentLocal(ctx context.Context, arg chat1.DownloadAttachmentLocalArg) (res chat1.DownloadAttachmentLocalRes, err error) {
	var identBreaks []keybase1.TLFIdentifyFailure
	ctx = globals.ChatCtx(ctx, h.G(), arg.IdentifyBehavior, &identBreaks, h.identNotifier)
	defer h.Trace(ctx, func() error { return err }, "DownloadAttachmentLocal")()
	defer func() { h.setResultRateLimit(ctx, &res) }()
	uid, err := utils.AssertLoggedInUID(ctx, h.G())
	if err != nil {
		return res, err
	}
	darg := downloadAttachmentArg{
		SessionID:        arg.SessionID,
		ConversationID:   arg.ConversationID,
		MessageID:        arg.MessageID,
		Preview:          arg.Preview,
		IdentifyBehavior: arg.IdentifyBehavior,
	}
	cli := h.getStreamUICli()
	darg.Sink = libkb.NewRemoteStreamBuffered(arg.Sink, cli, arg.SessionID)

	return h.downloadAttachmentLocal(ctx, uid, darg)
}
1035947
func (s *Bucket) InitiateMultipartUpload(objectKey string, input *InitiateMultipartUploadInput) (*InitiateMultipartUploadOutput, error) {
	r, x, err := s.InitiateMultipartUploadRequest(objectKey, input)

	if err != nil {
		return x, err
	}

	err = r.Send()
	if err != nil {
		return nil, err
	}

	requestID := r.HTTPResponse.Header.Get(http.CanonicalHeaderKey("X-QS-Request-ID"))
	x.RequestID = &requestID

	return x, err
}
395267
func (c *Client) UploadSubtitles(subs Subtitles) (string, error) {
	subArgs, err := subs.toUploadParams()
	if err != nil {
		return "", err
	}
	// XXX WIP
	// fmt.Println("Upload Params:", subArgs)
	return "", fmt.Errorf("WIP")

	args := []interface{}{c.Token, subArgs}
	res := struct {
		Status string `xmlrpc:"status"`
		URL    string `xmlrpc:"data"`
	}{}
	if err := c.Call("UploadSubtitles", args, &res); err != nil {
		return "", err
	}
	if res.Status != StatusSuccess {
		return "", fmt.Errorf("UploadSubtitles: %s", res.Status)
	}

	return res.URL, nil
}
1150286
func (p *Packet) TCPDataAttach(tcpOptions []byte, tcpData []byte) (err error) {

	if err = p.tcpDataAttach(tcpOptions, tcpData); err != nil {
		return fmt.Errorf("tcp data attachment failed: %s", err)
	}

	// We are increasing tcpOptions by 1 32-bit word. We are always adding
	// our option last.
	packetLenIncrease := uint16(len(tcpData) + len(tcpOptions))
	// IP Header Processing
	p.FixupIPHdrOnDataModify(p.ipHdr.ipTotalLength, p.ipHdr.ipTotalLength+packetLenIncrease)

	// TCP Header Processing
	p.FixuptcpHdrOnTCPDataAttach(tcpOptions, tcpData)

	return
}
938778
func (s *IssueService) PostAttachment(issueID string, r io.Reader, attachmentName string) (*[]Attachment, *Response, error) {
	apiEndpoint := fmt.Sprintf("rest/api/2/issue/%s/attachments", issueID)

	b := new(bytes.Buffer)
	writer := multipart.NewWriter(b)

	fw, err := writer.CreateFormFile("file", attachmentName)
	if err != nil {
		return nil, nil, err
	}

	if r != nil {
		// Copy the file
		if _, err = io.Copy(fw, r); err != nil {
			return nil, nil, err
		}
	}
	writer.Close()

	req, err := s.client.NewMultiPartRequest("POST", apiEndpoint, b)
	if err != nil {
		return nil, nil, err
	}

	req.Header.Set("Content-Type", writer.FormDataContentType())

	// PostAttachment response returns a JSON array (as multiple attachments can be posted)
	attachment := new([]Attachment)
	resp, err := s.client.Do(req, attachment)
	if err != nil {
		jerr := NewJiraError(resp, err)
		return nil, resp, jerr
	}

	return attachment, resp, nil
}
249170
func uploadAttachment(r io.Reader, ct string) (*att, error) {
	//combined AES-256 and HMAC-SHA256 key
	keys := make([]byte, 64)
	randBytes(keys)

	b, err := ioutil.ReadAll(r)
	if err != nil {
		return nil, err
	}

	e, err := aesEncrypt(keys[:32], b)
	if err != nil {
		return nil, err
	}

	m := appendMAC(keys[32:], e)

	id, location, err := allocateAttachment()
	if err != nil {
		return nil, err
	}
	err = putAttachment(location, m)
	if err != nil {
		return nil, err
	}
	return &att{id, ct, keys}, nil
}
602026
func NewSharedContentChangeInviteeRoleDetails(NewAccessLevel *sharing.AccessLevel, Invitee string) *SharedContentChangeInviteeRoleDetails {
	s := new(SharedContentChangeInviteeRoleDetails)
	s.NewAccessLevel = NewAccessLevel
	s.Invitee = Invitee
	return s
}
331762
func NewVideoUpload(chatID int64, file interface{}) VideoConfig {
	return VideoConfig{
		BaseFile: BaseFile{
			BaseChat:    BaseChat{ChatID: chatID},
			File:        file,
			UseExisting: false,
		},
	}
}