slack icon indicating copy to clipboard operation
slack copied to clipboard

Remote Image Quality Issue and Config Inquiry

Open inturipravallika opened this issue 11 months ago • 1 comments

What Happened

When uploading images to Slack using the files.remote.update API, the image quality noticeably deteriorates. This reduction in quality is not observed when using other Slack file upload APIs like files.upload. Is there any configuration or setting we can modify to preserve image quality during remote uploads?

Expected Behavior

Uploaded images should maintain their original quality, including resolution and sharpness.

Steps to Reproduce

  1. Use the files.upload API from Slack's messaging documentation (API link) to upload an image and observe the quality.
  2. Use files.remote.update API to update an image with the parameters provided below.
  3. Compare the image quality.

Reproducible Code

uploads := slack.UploadFileV2Parameters{
	Filetype:        "auto",
	Filename:        "Loading...",
	FileSize:        int(fileSize),
	Reader:          fileBuffer,
	Channels:        []string{n.BotEvent.ChannelID},
	Channel:         n.BotEvent.ChannelID,
	ThreadTimestamp: n.BotEvent.ThreadTimeStamp,
	Title:           appMentionTmpl.Title,
	//InitialComment:  appMentionTmpl.InitialComment,
}

uploadResp, er := n.Messenger.CompleteUploadExternal(ctx, uploads)

   payload := slack.RemoteFileParameters{
	ExternalID: s.uuidGenerator.New(),
	Title:      fmt.Sprintf("Model: %s", n.Data[ThreadWorksheetName]),
	// PreviewImage:       text,
	PreviewImageReader: nlsObject.Reader,
}
_, err = n.Messenger.UpdateRemoteFile(ctx, fileID, payload)
if err != nil {
	return fmt.Errorf("failed to update remote file: %w", err)
}

Versions

  • Go: v1.22.6
  • slack-go/slack:v0.14.0

inturipravallika avatar Jan 08 '25 13:01 inturipravallika

That's a bit of a misnomer. The files.remote.update doesn't upload your image to slack. You can provide a preview image to be sent but that's about it.

In effect, you're not uploading the image to Slack. You're just telling Slack where it can find your image.

Could you provide an example of an image url, and associated preview file you're trying to use in files.remote.update so that I can troubleshoot this further, just in case it has something to do with how we're handling the PreviewImageReader?

nlopes avatar May 10 '25 16:05 nlopes