Skip to content

Commit 584f1c5

Browse files
authored
Merge pull request #691 from SISheogorath/feature/upload
Allow more detailed configuration of upload mime types
2 parents e0389bc + a7935a5 commit 584f1c5

4 files changed

Lines changed: 29 additions & 11 deletions

File tree

app.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ var data = {
3535
version: config.version,
3636
GOOGLE_API_KEY: config.google.clientSecret,
3737
GOOGLE_CLIENT_ID: config.google.clientID,
38-
DROPBOX_APP_KEY: config.dropbox.appKey
38+
DROPBOX_APP_KEY: config.dropbox.appKey,
39+
allowedUploadMimeTypes: config.allowedUploadMimeTypes
3940
}
4041

4142
ejs.renderFile(constpath, data, {}, function (err, str) {

lib/config/index.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,26 @@ config.isLDAPEnable = config.ldap.url
9797
config.isSAMLEnable = config.saml.idpSsoUrl
9898
config.isPDFExportEnable = config.allowpdfexport
9999

100+
// figure out mime types for image uploads
101+
switch (config.imageUploadType) {
102+
case 'imgur':
103+
config.allowedUploadMimeTypes = [
104+
'image/jpeg',
105+
'image/png',
106+
'image/jpg',
107+
'image/gif'
108+
]
109+
break
110+
default:
111+
config.allowedUploadMimeTypes = [
112+
'image/jpeg',
113+
'image/png',
114+
'image/jpg',
115+
'image/gif',
116+
'image/svg+xml'
117+
]
118+
}
119+
100120
// generate correct path
101121
config.sslcapath.forEach(function (capath, i, array) {
102122
array[i] = path.resolve(appRootPath, capath)

public/js/lib/common/constant.ejs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ window.urlpath = '<%- urlpath %>'
33
window.debug = <%- debug %>
44
window.version = '<%- version %>'
55

6+
window.allowedUploadMimeTypes = <%- JSON.stringify(allowedUploadMimeTypes) %>
7+
68
window.GOOGLE_API_KEY = '<%- GOOGLE_API_KEY %>'
79
window.GOOGLE_CLIENT_ID = '<%- GOOGLE_CLIENT_ID %>'
8-
window.DROPBOX_APP_KEY = '<%- DROPBOX_APP_KEY %>'
10+
window.DROPBOX_APP_KEY = '<%- DROPBOX_APP_KEY %>'

public/vendor/inlineAttachment/inline-attachment.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,7 @@
141141
/**
142142
* Allowed MIME types
143143
*/
144-
allowedTypes: [
145-
'image/jpeg',
146-
'image/png',
147-
'image/jpg',
148-
'image/gif'
149-
],
144+
allowedTypes: window.allowedUploadMimeTypes,
150145

151146
/**
152147
* Text which will be inserted when dropping or pasting a file.
@@ -304,7 +299,7 @@
304299
if (this.settings.onFileUploadResponse.call(this, xhr) !== false) {
305300
var result = JSON.parse(xhr.responseText),
306301
filename = result[this.settings.jsonFieldName];
307-
302+
308303
if (result && filename) {
309304
var replacements = [];
310305
var string = this.settings.progressText.replace(this.filenameTag, id);
@@ -415,7 +410,7 @@
415410
// <http://wiki.ecmascript.org/doku.php?id=strawman:names>.
416411
//
417412
// The goals of this function are twofold:
418-
//
413+
//
419414
// * Provide a way to generate a string guaranteed to be unique when compared
420415
// to other strings generated by this function.
421416
// * Make the string complex enough that it is highly unlikely to be
@@ -432,4 +427,4 @@ var ID = function () {
432427
// Convert it to base 36 (numbers + letters), and grab the first 9 characters
433428
// after the decimal.
434429
return '_' + Math.random().toString(36).substr(2, 9);
435-
};
430+
};

0 commit comments

Comments
 (0)