File Uploads
Confused about "File Uploads"?
Let us know how we can improve our documentation:
The channel.sendImage
and channel.sendFile
methods make it easy to upload files.
How to upload a file or image
Copied!Confused about "How to upload a file or image"?
Let us know how we can improve our documentation:
Send image or file to Stream using the
sendImage
orsendFile
methods. It is recommended to also include attachmenttype:
to ensure proper handling by front end. (e.g. image, video, url)This will return a signed URL that points to your file on the Stream CDN. If the file is an image, it will be served inline with HTTP requests, or as an attachment otherwise.
Send message with URL as attachment.
Deleting Files and Images
Copied!Confused about "Deleting Files and Images"?
Let us know how we can improve our documentation:
We expose two methods for deleting files and images, channel.deleteImage
and channel.deleteFile
Requirements for Images
Copied!Confused about "Requirements for Images"?
Let us know how we can improve our documentation:
Stream supported image types are: image/bmp, image/gif, image/jpeg, image/png, image/webp, image/heic, image/heic-sequence, image/heif, image/heif-sequence, image/svg+xml.
You can set a more restrictive list for your application if needed.
The maximum file size is 100MB.
Requirements for Files
Copied!Confused about "Requirements for Files"?
Let us know how we can improve our documentation:
Stream will not block any file types from uploading, however, different clients may handle different types differently or not at all.
You can set a more restrictive list for your application if needed.
The maximum file size is 100MB.
How to Allow/Block file extensions
Copied!Confused about "How to Allow/Block file extensions"?
Let us know how we can improve our documentation:
Stream will allow any file extension. If you want to be more restrictive for an application, this is can be set via API or by logging into your dashboard.
To update via the dashboard, login and go to the Chat Overview page >> Upload Configuration
API updates are made using UpdateAppSettings, see the App Settings page
Image resizing
Copied!Confused about "Image resizing"?
Let us know how we can improve our documentation:
You can automatically resize an image appending query parameters to a valid image link stored on the Stream CDN.
There are four supported params - all of them are optional and can be used interchangeably:
Parameter | Type | Values | Description |
---|---|---|---|
w | number | Width | |
h | number | Height | |
resize | string |
| The resizing mode |
crop | string |
| The cropping direction during resize |
Access control and link expiration
Copied!Confused about "Access control and link expiration"?
Let us know how we can improve our documentation:
The Stream CDN URL returned during the upload contains a signature that validates the access to the file it points to. Only the members of a channel a file was uploaded to can see the attachment and its unique, signed link. Links can only be accessed with a valid signature, which also protects against enumeration attacks.
Whenever messages containing your attachments are retrieved (i.e., when querying a channel), the attachment links will contain a new, fresh signature.
A single Stream CDN URL expires after 14 days, after which its signature will stop working and the link won't be valid anymore. You can check when a link will expire by comparing the current time with the Unix timestamp in the Expires parameter of the link's query: https://us-east.stream-io-cdn.com/0000/images/foo.png?...&Expires=1602666347&...
As explained above, all operations that return messages will refresh links automatically, but if you are storing a message containing an expired link you can perform a getMessage
call to retrieve fresh links for its attachments.
Using Your Own CDN
Copied!Confused about "Using Your Own CDN"?
Let us know how we can improve our documentation:
All 5 SDKs make it easy to use your own CDN for uploads. The code examples below show how to change where files are uploaded: