summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2013-12-18 06:03:50 -0800
committerThomas Müller <thomas.mueller@tmit.eu>2013-12-18 06:03:50 -0800
commit277ae281718febddd82846ebbdf7ec3c6380bc07 (patch)
treefeebe2d043f8b264397cde727709dfdbff9ee29d /apps
parenta90342b78117967388db462fec2dc7fd70edc0fa (diff)
parent335b2f40a631f7188ab921d69289acaf31908c6e (diff)
downloadnextcloud-server-277ae281718febddd82846ebbdf7ec3c6380bc07.tar.gz
nextcloud-server-277ae281718febddd82846ebbdf7ec3c6380bc07.zip
Merge pull request #6295 from owncloud/files-fromlinkerrormessagefixes
Fixed download file from URL error messages
Diffstat (limited to 'apps')
-rw-r--r--apps/files/ajax/newfile.php28
-rw-r--r--apps/files/js/file-upload.js7
2 files changed, 26 insertions, 9 deletions
diff --git a/apps/files/ajax/newfile.php b/apps/files/ajax/newfile.php
index c327d2b9f94..ec5b716fb2a 100644
--- a/apps/files/ajax/newfile.php
+++ b/apps/files/ajax/newfile.php
@@ -53,13 +53,13 @@ $result = array(
);
if(trim($filename) === '') {
- $result['data'] = array('message' => $l10n->t('File name cannot be empty.'));
+ $result['data'] = array('message' => (string)$l10n->t('File name cannot be empty.'));
OCP\JSON::error($result);
exit();
}
if(strpos($filename, '/') !== false) {
- $result['data'] = array('message' => $l10n->t('File name must not contain "/". Please choose a different name.'));
+ $result['data'] = array('message' => (string)$l10n->t('File name must not contain "/". Please choose a different name.'));
OCP\JSON::error($result);
exit();
}
@@ -68,7 +68,7 @@ if(strpos($filename, '/') !== false) {
$target = $dir.'/'.$filename;
if (\OC\Files\Filesystem::file_exists($target)) {
- $result['data'] = array('message' => $l10n->t(
+ $result['data'] = array('message' => (string)$l10n->t(
'The name %s is already used in the folder %s. Please choose a different name.',
array($filename, $dir))
);
@@ -78,20 +78,32 @@ if (\OC\Files\Filesystem::file_exists($target)) {
if($source) {
if(substr($source, 0, 8)!='https://' and substr($source, 0, 7)!='http://') {
- OCP\JSON::error(array('data' => array( 'message' => $l10n->t('Not a valid source') )));
+ OCP\JSON::error(array('data' => array('message' => $l10n->t('Not a valid source'))));
+ exit();
+ }
+
+ if (!ini_get('allow_url_fopen')) {
+ $eventSource->send('error', array('message' => $l10n->t('Server is not allowed to open URLs, please check the server configuration')));
+ $eventSource->close();
exit();
}
$ctx = stream_context_create(null, array('notification' =>'progress'));
- $sourceStream=fopen($source, 'rb', false, $ctx);
- $result=\OC\Files\Filesystem::file_put_contents($target, $sourceStream);
+ $sourceStream=@fopen($source, 'rb', false, $ctx);
+ $result = 0;
+ if (is_resource($sourceStream)) {
+ $result=\OC\Files\Filesystem::file_put_contents($target, $sourceStream);
+ }
if($result) {
$meta = \OC\Files\Filesystem::getFileInfo($target);
$mime=$meta['mimetype'];
$id = $meta['fileid'];
- $eventSource->send('success', array('mime'=>$mime, 'size'=>\OC\Files\Filesystem::filesize($target), 'id' => $id, 'etag' => $meta['etag']));
+ $eventSource->send('success', array('mime' => $mime, 'size' => \OC\Files\Filesystem::filesize($target), 'id' => $id, 'etag' => $meta['etag']));
} else {
- $eventSource->send('error', $l10n->t('Error while downloading %s to %s', array($source, $target)));
+ $eventSource->send('error', array('message' => $l10n->t('Error while downloading %s to %s', array($source, $target))));
+ }
+ if (is_resource($sourceStream)) {
+ fclose($sourceStream);
}
$eventSource->close();
exit();
diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js
index e9663353f74..196817432d5 100644
--- a/apps/files/js/file-upload.js
+++ b/apps/files/js/file-upload.js
@@ -658,7 +658,12 @@ $(document).ready(function() {
});
eventSource.listen('error',function(error) {
$('#uploadprogressbar').fadeOut();
- alert(error);
+ var message = (error && error.message) || t('core', 'Error fetching URL');
+ OC.Notification.show(message);
+ //hide notification after 10 sec
+ setTimeout(function() {
+ OC.Notification.hide();
+ }, 10000);
});
break;
}