Upload a file with a password
This commit is contained in:
parent
8aac7bad45
commit
66655b4a23
@ -600,6 +600,8 @@ define(function () {
|
|||||||
out.upload_rename = "Souhaitez-vous renommer <b>{0}</b> avant son stockage en ligne ?<br>" +
|
out.upload_rename = "Souhaitez-vous renommer <b>{0}</b> avant son stockage en ligne ?<br>" +
|
||||||
"<em>L'extension du fichier ({1}) sera ajoutée automatiquement. "+
|
"<em>L'extension du fichier ({1}) sera ajoutée automatiquement. "+
|
||||||
"Ce nom sera permanent et visible par les autres utilisateurs</em>.";
|
"Ce nom sera permanent et visible par les autres utilisateurs</em>.";
|
||||||
|
out.upload_password = "Souhaitez-vous protéger ce fichier avec un mot de passe ?<br>" +
|
||||||
|
"Choisir <em>Ne plus demander</em> implique qu'aucun fichier importé durant cette session n'aura de mot de passe.";
|
||||||
out.upload_serverError = "Erreur interne: impossible d'importer le fichier pour l'instant.";
|
out.upload_serverError = "Erreur interne: impossible d'importer le fichier pour l'instant.";
|
||||||
out.upload_uploadPending = "Vous avez déjà un fichier en cours d'importation. Souhaitez-vous l'annuler et importer ce nouveau fichier ?";
|
out.upload_uploadPending = "Vous avez déjà un fichier en cours d'importation. Souhaitez-vous l'annuler et importer ce nouveau fichier ?";
|
||||||
out.upload_success = "Votre fichier ({0}) a été importé avec succès et ajouté à votre CryptDrive.";
|
out.upload_success = "Votre fichier ({0}) a été importé avec succès et ajouté à votre CryptDrive.";
|
||||||
|
|||||||
@ -604,6 +604,8 @@ define(function () {
|
|||||||
out.upload_rename = "Do you want to rename <b>{0}</b> before uploading it to the server?<br>" +
|
out.upload_rename = "Do you want to rename <b>{0}</b> before uploading it to the server?<br>" +
|
||||||
"<em>The file extension ({1}) will be added automatically. "+
|
"<em>The file extension ({1}) will be added automatically. "+
|
||||||
"This name will be permanent and visible to other users.</em>";
|
"This name will be permanent and visible to other users.</em>";
|
||||||
|
out.upload_password = "Do you want to protect your file with a password?<br>" +
|
||||||
|
"If you choose <em>Do not ask me again</em>, uploaded files won't have a password.";
|
||||||
out.upload_serverError = "Server Error: unable to upload your file at this time.";
|
out.upload_serverError = "Server Error: unable to upload your file at this time.";
|
||||||
out.upload_uploadPending = "You already have an upload in progress. Cancel it and upload your new file?";
|
out.upload_uploadPending = "You already have an upload in progress. Cancel it and upload your new file?";
|
||||||
out.upload_success = "Your file ({0}) has been successfully uploaded and added to your drive.";
|
out.upload_success = "Your file ({0}) has been successfully uploaded and added to your drive.";
|
||||||
|
|||||||
@ -425,9 +425,14 @@ define([
|
|||||||
cb = cb || function () {};
|
cb = cb || function () {};
|
||||||
opt = opt || {};
|
opt = opt || {};
|
||||||
|
|
||||||
var input = dialog.textInput();
|
var inputBlock = opt.password ? UI.passwordInput() : dialog.textInput();
|
||||||
|
var input = opt.password ? $(inputBlock).find('input')[0] : inputBlock;
|
||||||
input.value = typeof(def) === 'string'? def: '';
|
input.value = typeof(def) === 'string'? def: '';
|
||||||
|
|
||||||
|
if (opt.password) {
|
||||||
|
$(inputBlock).find('.cp-checkmark').css('margin-bottom', '15px');
|
||||||
|
}
|
||||||
|
|
||||||
var message;
|
var message;
|
||||||
if (typeof(msg) === 'string') {
|
if (typeof(msg) === 'string') {
|
||||||
if (!force) { msg = Util.fixHTML(msg); }
|
if (!force) { msg = Util.fixHTML(msg); }
|
||||||
@ -441,7 +446,7 @@ define([
|
|||||||
var cancel = dialog.cancelButton(opt.cancel);
|
var cancel = dialog.cancelButton(opt.cancel);
|
||||||
var frame = dialog.frame([
|
var frame = dialog.frame([
|
||||||
message,
|
message,
|
||||||
input,
|
inputBlock,
|
||||||
dialog.nav([ cancel, ok, ]),
|
dialog.nav([ cancel, ok, ]),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
@ -212,8 +212,10 @@ define([
|
|||||||
queue.next();
|
queue.next();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Don't show the rename prompt if we don't want to store the file in the drive (avatar)
|
// Don't show the rename and password prompts if we don't store the file in the drive
|
||||||
|
// e.g. avatar
|
||||||
var showNamePrompt = !config.noStore;
|
var showNamePrompt = !config.noStore;
|
||||||
|
var showPasswordPrompt = !config.noStore;
|
||||||
|
|
||||||
var promptName = function (file, cb) {
|
var promptName = function (file, cb) {
|
||||||
var extIdx = file.name.lastIndexOf('.');
|
var extIdx = file.name.lastIndexOf('.');
|
||||||
@ -225,6 +227,7 @@ define([
|
|||||||
]);
|
]);
|
||||||
UI.prompt(msg, name, function (newName) {
|
UI.prompt(msg, name, function (newName) {
|
||||||
if (newName === null) {
|
if (newName === null) {
|
||||||
|
// "Don't ask me again"
|
||||||
showNamePrompt = false;
|
showNamePrompt = false;
|
||||||
return void cb (file.name);
|
return void cb (file.name);
|
||||||
}
|
}
|
||||||
@ -235,6 +238,19 @@ define([
|
|||||||
cb(newName);
|
cb(newName);
|
||||||
}, {cancel: Messages.doNotAskAgain}, true);
|
}, {cancel: Messages.doNotAskAgain}, true);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var promptPassword = function (file, cb) {
|
||||||
|
var msg = Messages.upload_password;
|
||||||
|
UI.prompt(msg, '', function (password) {
|
||||||
|
if (password === null) {
|
||||||
|
// "Don't ask me again"
|
||||||
|
showPasswordPrompt = false;
|
||||||
|
return void cb ();
|
||||||
|
}
|
||||||
|
cb(password);
|
||||||
|
}, {cancel: Messages.doNotAskAgain, password: true}, true);
|
||||||
|
};
|
||||||
|
|
||||||
var handleFileState = {
|
var handleFileState = {
|
||||||
queue: [],
|
queue: [],
|
||||||
inProgress: false
|
inProgress: false
|
||||||
@ -246,6 +262,7 @@ define([
|
|||||||
var thumb;
|
var thumb;
|
||||||
var file_arraybuffer;
|
var file_arraybuffer;
|
||||||
var name = file.name;
|
var name = file.name;
|
||||||
|
var password;
|
||||||
var finish = function () {
|
var finish = function () {
|
||||||
var metadata = {
|
var metadata = {
|
||||||
name: name,
|
name: name,
|
||||||
@ -255,6 +272,7 @@ define([
|
|||||||
queue.push({
|
queue.push({
|
||||||
blob: file_arraybuffer,
|
blob: file_arraybuffer,
|
||||||
metadata: metadata,
|
metadata: metadata,
|
||||||
|
password: password,
|
||||||
dropEvent: e
|
dropEvent: e
|
||||||
});
|
});
|
||||||
handleFileState.inProgress = false;
|
handleFileState.inProgress = false;
|
||||||
@ -263,11 +281,18 @@ define([
|
|||||||
handleFile(next[0], next[1]);
|
handleFile(next[0], next[1]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
var getPassword = function () {
|
||||||
|
if (!showPasswordPrompt) { return void finish(); }
|
||||||
|
promptPassword(file, function (pw) {
|
||||||
|
password = pw;
|
||||||
|
finish();
|
||||||
|
});
|
||||||
|
};
|
||||||
var getName = function () {
|
var getName = function () {
|
||||||
if (!showNamePrompt) { return void finish(); }
|
if (!showNamePrompt) { return void getPassword(); }
|
||||||
promptName(file, function (newName) {
|
promptName(file, function (newName) {
|
||||||
name = newName;
|
name = newName;
|
||||||
finish();
|
getPassword();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user