Skip to content

Commit

Permalink
Add '&asatt=1' to URL to request 'Content-Disposition: attachment' re…
Browse files Browse the repository at this point in the history
…sponse header
  • Loading branch information
or-else committed Apr 15, 2023
1 parent f40eebc commit 01f5f9a
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tinode-sdk",
"description": "Tinode SDK",
"version": "0.22.2",
"version": "0.22.3",
"scripts": {
"format": "js-beautify -r src/*.js",
"build": "npm run format && npm run vers && npm run build:prod && npm run build:dev",
Expand Down
9 changes: 9 additions & 0 deletions src/large-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ import {

let XHRProvider;

function addURLParam(relUrl, key, value) {
const url = new URL(relUrl, window.location.origin);
url.searchParams.append(key, value);
return url.toString().substring(window.location.origin.length);
}

/**
* @class LargeFileHelper - utilities for uploading and downloading files out of band.
* Don't instantiate this class directly. Use {Tinode.getLargeFileHelper} instead.
Expand Down Expand Up @@ -207,6 +213,9 @@ export default class LargeFileHelper {
const xhr = new XHRProvider();
this.xhr.push(xhr);

// Add '&asatt=1' to URL to request 'Content-Disposition: attachment' response header.
relativeUrl = addURLParam(relativeUrl, 'asatt', '1');

// Get data as blob (stored by the browser as a temporary file).
xhr.open('GET', relativeUrl, true);
xhr.setRequestHeader('X-Tinode-APIKey', this._apiKey);
Expand Down
8 changes: 7 additions & 1 deletion umd/tinode.dev.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion umd/tinode.dev.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion umd/tinode.prod.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion umd/tinode.prod.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion version.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const PACKAGE_VERSION = "0.22.2";
export const PACKAGE_VERSION = "0.22.3";

0 comments on commit 01f5f9a

Please sign in to comment.