2015-07-08 18:25:27 +03:00
|
|
|
/*
|
2016-01-07 07:06:39 +03:00
|
|
|
Copyright 2015, 2016 OpenMarket Ltd
|
2018-04-24 18:05:14 +03:00
|
|
|
Copyright 2018 New Vector Ltd
|
2015-07-08 18:25:27 +03:00
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2019-12-08 15:16:17 +03:00
|
|
|
import React, {createRef} from 'react';
|
2017-12-26 04:03:18 +03:00
|
|
|
import PropTypes from 'prop-types';
|
2016-11-08 15:57:24 +03:00
|
|
|
import filesize from 'filesize';
|
2019-12-21 00:13:46 +03:00
|
|
|
import {MatrixClientPeg} from '../../../MatrixClientPeg';
|
2019-12-20 04:19:56 +03:00
|
|
|
import * as sdk from '../../../index';
|
2017-05-25 13:39:08 +03:00
|
|
|
import { _t } from '../../../languageHandler';
|
2016-11-08 15:57:24 +03:00
|
|
|
import {decryptFile} from '../../../utils/DecryptFile';
|
2016-11-16 17:16:51 +03:00
|
|
|
import Tinter from '../../../Tinter';
|
2016-11-26 02:19:20 +03:00
|
|
|
import request from 'browser-request';
|
2016-11-18 23:08:26 +03:00
|
|
|
import Modal from '../../../Modal';
|
2020-02-08 01:07:29 +03:00
|
|
|
import AccessibleButton from "../elements/AccessibleButton";
|
2016-11-18 23:08:26 +03:00
|
|
|
|
2016-11-16 17:16:51 +03:00
|
|
|
|
2019-01-11 04:37:28 +03:00
|
|
|
// A cached tinted copy of require("../../../../res/img/download.svg")
|
2017-10-11 19:56:17 +03:00
|
|
|
let tintedDownloadImageURL;
|
2016-11-16 17:16:51 +03:00
|
|
|
// Track a list of mounted MFileBody instances so that we can update
|
2019-01-11 04:37:28 +03:00
|
|
|
// the require("../../../../res/img/download.svg") when the tint changes.
|
2017-10-11 19:56:17 +03:00
|
|
|
let nextMountId = 0;
|
2016-11-16 17:16:51 +03:00
|
|
|
const mounts = {};
|
|
|
|
|
|
|
|
/**
|
2019-01-11 04:37:28 +03:00
|
|
|
* Updates the tinted copy of require("../../../../res/img/download.svg") when the tint changes.
|
2016-11-16 17:16:51 +03:00
|
|
|
*/
|
|
|
|
function updateTintedDownloadImage() {
|
|
|
|
// Download the svg as an XML document.
|
|
|
|
// We could cache the XML response here, but since the tint rarely changes
|
|
|
|
// it's probably not worth it.
|
2016-11-26 02:19:20 +03:00
|
|
|
// Also note that we can't use fetch here because fetch doesn't support
|
|
|
|
// file URLs, which the download image will be if we're running from
|
|
|
|
// the filesystem (like in an Electron wrapper).
|
2019-01-11 04:37:28 +03:00
|
|
|
request({uri: require("../../../../res/img/download.svg")}, (err, response, body) => {
|
2016-11-26 02:19:20 +03:00
|
|
|
if (err) return;
|
|
|
|
|
|
|
|
const svg = new DOMParser().parseFromString(body, "image/svg+xml");
|
2016-11-16 17:16:51 +03:00
|
|
|
// Apply the fixups to the XML.
|
|
|
|
const fixups = Tinter.calcSvgFixups([{contentDocument: svg}]);
|
|
|
|
Tinter.applySvgFixups(fixups);
|
|
|
|
// Encoded the fixed up SVG as a data URL.
|
|
|
|
const svgString = new XMLSerializer().serializeToString(svg);
|
|
|
|
tintedDownloadImageURL = "data:image/svg+xml;base64," + window.btoa(svgString);
|
|
|
|
// Notify each mounted MFileBody that the URL has changed.
|
|
|
|
Object.keys(mounts).forEach(function(id) {
|
|
|
|
mounts[id].tint();
|
|
|
|
});
|
2016-11-26 02:19:20 +03:00
|
|
|
});
|
2016-11-16 17:16:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
Tinter.registerTintable(updateTintedDownloadImage);
|
2016-11-04 18:39:39 +03:00
|
|
|
|
2016-12-02 17:21:07 +03:00
|
|
|
// User supplied content can contain scripts, we have to be careful that
|
|
|
|
// we don't accidentally run those script within the same origin as the
|
|
|
|
// client. Otherwise those scripts written by remote users can read
|
|
|
|
// the access token and end-to-end keys that are in local storage.
|
|
|
|
//
|
|
|
|
// For attachments downloaded directly from the homeserver we can use
|
|
|
|
// Content-Security-Policy headers to disable script execution.
|
|
|
|
//
|
|
|
|
// But attachments with end-to-end encryption are more difficult to handle.
|
|
|
|
// We need to decrypt the attachment on the client and then display it.
|
|
|
|
// To display the attachment we need to turn the decrypted bytes into a URL.
|
|
|
|
//
|
|
|
|
// There are two ways to turn bytes into URLs, data URL and blob URLs.
|
|
|
|
// Data URLs aren't suitable for downloading a file because Chrome has a
|
|
|
|
// 2MB limit on the size of URLs that can be viewed in the browser or
|
|
|
|
// downloaded. This limit does not seem to apply when the url is used as
|
|
|
|
// the source attribute of an image tag.
|
|
|
|
//
|
2018-02-15 23:20:19 +03:00
|
|
|
// Blob URLs are generated using window.URL.createObjectURL and unfortunately
|
2016-12-02 17:21:07 +03:00
|
|
|
// for our purposes they inherit the origin of the page that created them.
|
|
|
|
// This means that any scripts that run when the URL is viewed will be able
|
|
|
|
// to access local storage.
|
|
|
|
//
|
|
|
|
// The easiest solution is to host the code that generates the blob URL on
|
|
|
|
// a different domain to the client.
|
|
|
|
// Another possibility is to generate the blob URL within a sandboxed iframe.
|
|
|
|
// The downside of using a second domain is that it complicates hosting,
|
|
|
|
// the downside of using a sandboxed iframe is that the browers are overly
|
|
|
|
// restrictive in what you are allowed to do with the generated URL.
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the current CSS style for a DOMElement.
|
|
|
|
* @param {HTMLElement} element The element to get the current style of.
|
|
|
|
* @return {string} The CSS style encoded as a string.
|
|
|
|
*/
|
|
|
|
function computedStyle(element) {
|
|
|
|
if (!element) {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
const style = window.getComputedStyle(element, null);
|
2017-10-11 19:56:17 +03:00
|
|
|
let cssText = style.cssText;
|
2016-12-02 17:21:07 +03:00
|
|
|
if (cssText == "") {
|
|
|
|
// Firefox doesn't implement ".cssText" for computed styles.
|
|
|
|
// https://bugzilla.mozilla.org/show_bug.cgi?id=137687
|
2017-10-11 19:56:17 +03:00
|
|
|
for (let i = 0; i < style.length; i++) {
|
2016-12-02 17:21:07 +03:00
|
|
|
cssText += style[i] + ":";
|
|
|
|
cssText += style.getPropertyValue(style[i]) + ";";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return cssText;
|
|
|
|
}
|
|
|
|
|
2020-08-29 14:14:16 +03:00
|
|
|
export default class MFileBody extends React.Component {
|
|
|
|
static propTypes = {
|
2019-03-07 19:00:10 +03:00
|
|
|
/* the MatrixEvent to show */
|
|
|
|
mxEvent: PropTypes.object.isRequired,
|
|
|
|
/* already decrypted blob */
|
|
|
|
decryptedBlob: PropTypes.object,
|
|
|
|
/* called when the download link iframe is shown */
|
|
|
|
onHeightChanged: PropTypes.func,
|
|
|
|
/* the shape of the tile, used */
|
|
|
|
tileShape: PropTypes.string,
|
2020-08-29 14:14:16 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
this.state = {
|
|
|
|
decryptedBlob: (this.props.decryptedBlob ? this.props.decryptedBlob : null),
|
|
|
|
};
|
|
|
|
|
|
|
|
this._iframe = createRef();
|
|
|
|
this._dummyLink = createRef();
|
|
|
|
this._downloadImage = createRef();
|
|
|
|
}
|
2019-03-07 19:00:10 +03:00
|
|
|
|
2016-11-15 18:54:14 +03:00
|
|
|
/**
|
|
|
|
* Extracts a human readable label for the file attachment to use as
|
|
|
|
* link text.
|
|
|
|
*
|
2020-10-30 21:18:17 +03:00
|
|
|
* @param {Object} content The "content" key of the matrix event.
|
2016-11-15 18:54:14 +03:00
|
|
|
* @return {string} the human readable link text for the attachment.
|
|
|
|
*/
|
2020-08-29 14:14:16 +03:00
|
|
|
presentableTextForFile(content) {
|
2017-10-11 19:56:17 +03:00
|
|
|
let linkText = _t("Attachment");
|
2015-07-08 18:25:27 +03:00
|
|
|
if (content.body && content.body.length > 0) {
|
2016-11-15 18:54:14 +03:00
|
|
|
// The content body should be the name of the file including a
|
|
|
|
// file extension.
|
2015-07-08 18:25:27 +03:00
|
|
|
linkText = content.body;
|
|
|
|
}
|
|
|
|
|
2016-11-15 18:54:14 +03:00
|
|
|
if (content.info && content.info.size) {
|
|
|
|
// If we know the size of the file then add it as human readable
|
|
|
|
// string to the end of the link text so that the user knows how
|
|
|
|
// big a file they are downloading.
|
|
|
|
// The content.info also contains a MIME-type but we don't display
|
|
|
|
// it since it is "ugly", users generally aren't aware what it
|
|
|
|
// means and the type of the attachment can usually be inferrered
|
|
|
|
// from the file extension.
|
|
|
|
linkText += ' (' + filesize(content.info.size) + ')';
|
2015-07-08 18:25:27 +03:00
|
|
|
}
|
|
|
|
return linkText;
|
2020-08-29 14:14:16 +03:00
|
|
|
}
|
2015-11-27 18:02:32 +03:00
|
|
|
|
2020-08-29 14:14:16 +03:00
|
|
|
_getContentUrl() {
|
2016-11-08 14:42:20 +03:00
|
|
|
const content = this.props.mxEvent.getContent();
|
2016-12-02 17:21:07 +03:00
|
|
|
return MatrixClientPeg.get().mxcUrlToHttp(content.url);
|
2020-08-29 14:14:16 +03:00
|
|
|
}
|
2019-12-08 15:16:17 +03:00
|
|
|
|
2020-08-29 14:14:16 +03:00
|
|
|
componentDidMount() {
|
2016-11-16 17:16:51 +03:00
|
|
|
// Add this to the list of mounted components to receive notifications
|
|
|
|
// when the tint changes.
|
|
|
|
this.id = nextMountId++;
|
|
|
|
mounts[this.id] = this;
|
|
|
|
this.tint();
|
2020-08-29 14:14:16 +03:00
|
|
|
}
|
2016-11-04 17:00:26 +03:00
|
|
|
|
2020-08-29 14:14:16 +03:00
|
|
|
componentDidUpdate(prevProps, prevState) {
|
2019-03-07 19:00:10 +03:00
|
|
|
if (this.props.onHeightChanged && !prevState.decryptedBlob && this.state.decryptedBlob) {
|
|
|
|
this.props.onHeightChanged();
|
|
|
|
}
|
2020-08-29 14:14:16 +03:00
|
|
|
}
|
2019-03-07 19:00:10 +03:00
|
|
|
|
2020-08-29 14:14:16 +03:00
|
|
|
componentWillUnmount() {
|
2016-11-16 17:16:51 +03:00
|
|
|
// Remove this from the list of mounted components
|
|
|
|
delete mounts[this.id];
|
2020-08-29 14:14:16 +03:00
|
|
|
}
|
2016-11-16 17:16:51 +03:00
|
|
|
|
2020-08-29 14:14:16 +03:00
|
|
|
tint = () => {
|
2019-01-11 04:37:28 +03:00
|
|
|
// Update our tinted copy of require("../../../../res/img/download.svg")
|
2019-12-08 15:16:17 +03:00
|
|
|
if (this._downloadImage.current) {
|
|
|
|
this._downloadImage.current.src = tintedDownloadImageURL;
|
2016-11-16 17:16:51 +03:00
|
|
|
}
|
2019-12-08 15:16:17 +03:00
|
|
|
if (this._iframe.current) {
|
2016-12-02 17:21:07 +03:00
|
|
|
// If the attachment is encrypted then the download image
|
|
|
|
// will be inside the iframe so we wont be able to update
|
|
|
|
// it directly.
|
2019-12-08 15:16:17 +03:00
|
|
|
this._iframe.current.contentWindow.postMessage({
|
2016-12-02 17:21:07 +03:00
|
|
|
imgSrc: tintedDownloadImageURL,
|
2019-12-08 15:16:17 +03:00
|
|
|
style: computedStyle(this._dummyLink.current),
|
2016-12-02 17:21:07 +03:00
|
|
|
}, "*");
|
|
|
|
}
|
2020-08-29 14:14:16 +03:00
|
|
|
};
|
2016-11-16 17:16:51 +03:00
|
|
|
|
2020-08-29 14:14:16 +03:00
|
|
|
render() {
|
2016-11-08 14:42:20 +03:00
|
|
|
const content = this.props.mxEvent.getContent();
|
|
|
|
const text = this.presentableTextForFile(content);
|
2016-12-02 17:21:07 +03:00
|
|
|
const isEncrypted = content.file !== undefined;
|
2017-05-23 17:16:31 +03:00
|
|
|
const fileName = content.body && content.body.length > 0 ? content.body : _t("Attachment");
|
2016-12-02 17:21:07 +03:00
|
|
|
const contentUrl = this._getContentUrl();
|
2016-11-18 23:08:26 +03:00
|
|
|
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
2019-03-29 23:12:48 +03:00
|
|
|
const fileSize = content.info ? content.info.size : null;
|
|
|
|
const fileType = content.info ? content.info.mimetype : "application/octet-stream";
|
2015-11-27 18:02:32 +03:00
|
|
|
|
2016-12-02 17:21:07 +03:00
|
|
|
if (isEncrypted) {
|
|
|
|
if (this.state.decryptedBlob === null) {
|
|
|
|
// Need to decrypt the attachment
|
|
|
|
// Wait for the user to click on the link before downloading
|
|
|
|
// and decrypting the attachment.
|
2017-10-11 19:56:17 +03:00
|
|
|
let decrypting = false;
|
2020-02-08 01:07:29 +03:00
|
|
|
const decrypt = (e) => {
|
2016-12-02 17:21:07 +03:00
|
|
|
if (decrypting) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
decrypting = true;
|
|
|
|
decryptFile(content.file).then((blob) => {
|
|
|
|
this.setState({
|
|
|
|
decryptedBlob: blob,
|
|
|
|
});
|
|
|
|
}).catch((err) => {
|
2017-01-20 17:22:27 +03:00
|
|
|
console.warn("Unable to decrypt attachment: ", err);
|
2017-08-10 15:49:11 +03:00
|
|
|
Modal.createTrackedDialog('Error decrypting attachment', '', ErrorDialog, {
|
2017-07-27 19:19:18 +03:00
|
|
|
title: _t("Error"),
|
2017-05-23 17:16:31 +03:00
|
|
|
description: _t("Error decrypting attachment"),
|
2016-12-02 17:21:07 +03:00
|
|
|
});
|
|
|
|
}).finally(() => {
|
|
|
|
decrypting = false;
|
2016-11-18 23:08:26 +03:00
|
|
|
});
|
2016-12-02 17:21:07 +03:00
|
|
|
};
|
|
|
|
|
2020-03-03 14:03:40 +03:00
|
|
|
// This button should actually Download because usercontent/ will try to click itself
|
|
|
|
// but it is not guaranteed between various browsers' settings.
|
2016-12-02 17:21:07 +03:00
|
|
|
return (
|
2019-12-08 15:12:06 +03:00
|
|
|
<span className="mx_MFileBody">
|
2018-01-30 13:55:23 +03:00
|
|
|
<div className="mx_MFileBody_download">
|
2020-02-08 01:07:29 +03:00
|
|
|
<AccessibleButton onClick={decrypt}>
|
2017-05-23 17:16:31 +03:00
|
|
|
{ _t("Decrypt %(text)s", { text: text }) }
|
2020-02-08 01:07:29 +03:00
|
|
|
</AccessibleButton>
|
2016-12-02 17:21:07 +03:00
|
|
|
</div>
|
|
|
|
</span>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// When the iframe loads we tell it to render a download link
|
|
|
|
const onIframeLoad = (ev) => {
|
|
|
|
ev.target.contentWindow.postMessage({
|
|
|
|
imgSrc: tintedDownloadImageURL,
|
2019-12-08 15:16:17 +03:00
|
|
|
style: computedStyle(this._dummyLink.current),
|
2016-12-02 17:21:07 +03:00
|
|
|
blob: this.state.decryptedBlob,
|
|
|
|
// Set a download attribute for encrypted files so that the file
|
|
|
|
// will have the correct name when the user tries to download it.
|
|
|
|
// We can't provide a Content-Disposition header like we would for HTTP.
|
|
|
|
download: fileName,
|
2017-05-23 17:16:31 +03:00
|
|
|
textContent: _t("Download %(text)s", { text: text }),
|
2020-03-03 16:23:33 +03:00
|
|
|
// only auto-download if a user triggered this iframe explicitly
|
|
|
|
auto: !this.props.decryptedBlob,
|
2016-12-02 17:21:07 +03:00
|
|
|
}, "*");
|
2016-11-18 23:08:26 +03:00
|
|
|
};
|
|
|
|
|
2020-02-13 19:53:45 +03:00
|
|
|
const url = "usercontent/"; // XXX: this path should probably be passed from the skin
|
|
|
|
|
2020-02-08 01:07:29 +03:00
|
|
|
// If the attachment is encrypted then put the link inside an iframe.
|
2016-11-04 17:00:26 +03:00
|
|
|
return (
|
2016-12-02 17:21:07 +03:00
|
|
|
<span className="mx_MFileBody">
|
2018-01-30 13:55:23 +03:00
|
|
|
<div className="mx_MFileBody_download">
|
2016-12-02 17:21:07 +03:00
|
|
|
<div style={{display: "none"}}>
|
2017-10-11 19:56:17 +03:00
|
|
|
{ /*
|
2016-12-02 17:21:07 +03:00
|
|
|
* Add dummy copy of the "a" tag
|
|
|
|
* We'll use it to learn how the download link
|
|
|
|
* would have been styled if it was rendered inline.
|
2017-10-11 19:56:17 +03:00
|
|
|
*/ }
|
2019-12-08 15:16:17 +03:00
|
|
|
<a ref={this._dummyLink} />
|
2016-12-02 17:21:07 +03:00
|
|
|
</div>
|
2020-02-13 19:53:45 +03:00
|
|
|
<iframe
|
2021-02-16 21:03:12 +03:00
|
|
|
src={url}
|
2020-02-13 19:53:45 +03:00
|
|
|
onLoad={onIframeLoad}
|
|
|
|
ref={this._iframe}
|
2020-03-03 14:03:40 +03:00
|
|
|
sandbox="allow-scripts allow-downloads allow-downloads-without-user-activation" />
|
2016-11-18 23:08:26 +03:00
|
|
|
</div>
|
2016-11-04 17:00:26 +03:00
|
|
|
</span>
|
|
|
|
);
|
2016-12-02 17:21:07 +03:00
|
|
|
} else if (contentUrl) {
|
2019-03-29 23:12:48 +03:00
|
|
|
const downloadProps = {
|
|
|
|
target: "_blank",
|
2020-02-24 01:14:29 +03:00
|
|
|
rel: "noreferrer noopener",
|
2019-03-29 23:12:48 +03:00
|
|
|
|
|
|
|
// We set the href regardless of whether or not we intercept the download
|
|
|
|
// because we don't really want to convert the file to a blob eagerly, and
|
|
|
|
// still want "open in new tab" and "save link as" to work.
|
|
|
|
href: contentUrl,
|
|
|
|
};
|
|
|
|
|
|
|
|
// Blobs can only have up to 500mb, so if the file reports as being too large then
|
|
|
|
// we won't try and convert it. Likewise, if the file size is unknown then we'll assume
|
|
|
|
// it is too big. There is the risk of the reported file size and the actual file size
|
|
|
|
// being different, however the user shouldn't normally run into this problem.
|
|
|
|
const fileTooBig = typeof(fileSize) === 'number' ? fileSize > 524288000 : true;
|
|
|
|
|
|
|
|
if (["application/pdf"].includes(fileType) && !fileTooBig) {
|
|
|
|
// We want to force a download on this type, so use an onClick handler.
|
|
|
|
downloadProps["onClick"] = (e) => {
|
|
|
|
console.log(`Downloading ${fileType} as blob (unencrypted)`);
|
|
|
|
|
|
|
|
// Avoid letting the <a> do its thing
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
|
|
|
|
// Start a fetch for the download
|
|
|
|
// Based upon https://stackoverflow.com/a/49500465
|
2019-03-30 00:48:33 +03:00
|
|
|
fetch(contentUrl).then((response) => response.blob()).then((blob) => {
|
2019-03-29 23:12:48 +03:00
|
|
|
const blobUrl = URL.createObjectURL(blob);
|
|
|
|
|
|
|
|
// We have to create an anchor to download the file
|
|
|
|
const tempAnchor = document.createElement('a');
|
|
|
|
tempAnchor.download = fileName;
|
|
|
|
tempAnchor.href = blobUrl;
|
|
|
|
document.body.appendChild(tempAnchor); // for firefox: https://stackoverflow.com/a/32226068
|
|
|
|
tempAnchor.click();
|
|
|
|
tempAnchor.remove();
|
|
|
|
});
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
// Else we are hoping the browser will do the right thing
|
|
|
|
downloadProps["download"] = fileName;
|
|
|
|
}
|
|
|
|
|
2016-12-02 17:21:07 +03:00
|
|
|
// If the attachment is not encrypted then we check whether we
|
|
|
|
// are being displayed in the room timeline or in a list of
|
|
|
|
// files in the right hand side of the screen.
|
2016-09-11 04:14:27 +03:00
|
|
|
if (this.props.tileShape === "file_grid") {
|
|
|
|
return (
|
|
|
|
<span className="mx_MFileBody">
|
2018-01-30 13:55:23 +03:00
|
|
|
<div className="mx_MFileBody_download">
|
2019-03-29 23:12:48 +03:00
|
|
|
<a className="mx_MFileBody_downloadLink" {...downloadProps}>
|
2016-11-04 21:09:12 +03:00
|
|
|
{ fileName }
|
2016-09-11 04:14:27 +03:00
|
|
|
</a>
|
|
|
|
<div className="mx_MImageBody_size">
|
|
|
|
{ content.info && content.info.size ? filesize(content.info.size) : "" }
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</span>
|
|
|
|
);
|
2017-10-11 19:56:17 +03:00
|
|
|
} else {
|
2016-09-11 04:14:27 +03:00
|
|
|
return (
|
|
|
|
<span className="mx_MFileBody">
|
2018-01-30 13:55:23 +03:00
|
|
|
<div className="mx_MFileBody_download">
|
2019-03-29 23:12:48 +03:00
|
|
|
<a {...downloadProps}>
|
2019-12-08 15:16:17 +03:00
|
|
|
<img src={tintedDownloadImageURL} width="12" height="14" ref={this._downloadImage} />
|
2017-05-23 17:16:31 +03:00
|
|
|
{ _t("Download %(text)s", { text: text }) }
|
2016-09-11 04:14:27 +03:00
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</span>
|
|
|
|
);
|
|
|
|
}
|
2015-11-27 18:02:32 +03:00
|
|
|
} else {
|
2017-10-11 19:56:17 +03:00
|
|
|
const extra = text ? (': ' + text) : '';
|
2016-01-03 03:11:11 +03:00
|
|
|
return <span className="mx_MFileBody">
|
2017-05-23 17:16:31 +03:00
|
|
|
{ _t("Invalid file%(extra)s", { extra: extra }) }
|
2017-01-20 17:22:27 +03:00
|
|
|
</span>;
|
2015-11-27 18:02:32 +03:00
|
|
|
}
|
2020-08-29 14:14:16 +03:00
|
|
|
}
|
|
|
|
}
|