Skip to content
This repository has been archived by the owner on Jan 7, 2020. It is now read-only.

Commit

Permalink
Merge pull request #76 from krishnaIndia/v0.5_patch
Browse files Browse the repository at this point in the history
fix/file_stream: Resolve file upload error
  • Loading branch information
hitman401 committed Jun 30, 2016
2 parents 7b23b8e + 9c50a00 commit 0a276ea
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
6 changes: 4 additions & 2 deletions demo_app/app/scripts/controllers/public_id_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ window.maidsafeDemo.controller('PublicIdCtrl', [ '$scope', '$rootScope', 'safeAp
return $rootScope.prompt.show('Invalid data', 'Please enter a valid Public ID');
}

if (!(new RegExp('^[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9](?:)+$')).test($scope.publicId)) {
if (!(new RegExp('^[a-z0-9][a-z0-9-]{1,61}[a-z0-9](?:)+$')).test($scope.publicId)) {
return $rootScope.prompt.show('Invalid data',
'Public ID entered is invalid', function() {
'Public ID should be lower case and should not contain special characters \
or space. In addition \'-\' is permitted if it is not at the \
start or end', function() {
$scope.publicId = '';
$scope.$applyAsync();
});
Expand Down
7 changes: 4 additions & 3 deletions demo_app/app/scripts/controllers/service_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ window.maidsafeDemo.controller('ServiceCtrl', [ '$scope', '$state', '$rootScope'
$scope.newServicePath = '/public';

$scope.longName = safe.getUserLongName();
var serviceCheck = /^[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$/;
var serviceCheck = /^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$/;

// get services
$scope.getServices = function() {
Expand Down Expand Up @@ -65,7 +65,8 @@ window.maidsafeDemo.controller('ServiceCtrl', [ '$scope', '$state', '$rootScope'
}
if (!serviceCheck.test($scope.serviceName)) {
return $rootScope.prompt.show('Invalid input',
'Service name should not contain special characters and space. In addition the hyphen is permitted if it is surrounded by characters, digits or hyphens, although it is not to start or end a label',
'Service name should be lower case and should not contain special characters\
or space. In addition \'-\' is permitted if it is not at the start or end',
function() {
$scope.serviceName = '';
$scope.$applyAsync();
Expand All @@ -90,7 +91,7 @@ window.maidsafeDemo.controller('ServiceCtrl', [ '$scope', '$state', '$rootScope'
$state.go('manageService');
}, {
title: 'Reason',
ctx: err.data.description
ctx: err.data.description
});
}
msg = $state.params.serviceName + ' service has been published successfully';
Expand Down
22 changes: 20 additions & 2 deletions demo_app/app/scripts/factories/nfs_factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,26 @@ window.maidsafeDemo.factory('nfsFactory', [ function(Shared) {
auth: {
'bearer': self.getAuthToken()
}
}, function(err) {
callback(err);
}, function(e, response) {
if (response.statusCode !== 200) {
var errMsg = response.body;
if (!response.statusCode) {
errMsg = {
errorCode: 400,
description: 'Request connection closed abruptly'
}
} else {
try {
errMsg = JSON.parse(errMsg);
} catch(e) {
errMsg = {
errorCode: 400,
description: errMsg
}
}
}
callback({data: !response.statusCode ? 'Request connection closed' : JSON.parse(response.body)});
}
}));
};

Expand Down

0 comments on commit 0a276ea

Please sign in to comment.