Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Update image url #158

Merged
merged 7 commits into from
Sep 8, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/index.jade
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,13 @@ html
script(src='../bower_components/x2js/xml2json.min.js')
script(src='../bower_components/angular-xml/angular-xml.js')
script(src='../bower_components/appirio-tech-ng-iso-constants/dist/ng-iso-constants.js')
script(src='../bower_components/d3/d3.js')
script(src='../bower_components/jstzdetect/jstz.min.js')
script(src='../bower_components/moment/moment.js')
script(src='../bower_components/ng-notifications-bar/dist/ngNotificationsBar.min.js')
script(src='../bower_components/ngDialog/js/ngDialog.js')
script(src='../bower_components/lodash/lodash.js')
script(src='../bower_components/restangular/dist/restangular.js')
script(src='../bower_components/d3/d3.js')
//- endbower
//- inject:nonBowerScripts
script(src="/scripts/auth0.js")
Expand Down
2 changes: 1 addition & 1 deletion app/services/api.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
route: 'members'
})
.addRequestInterceptor(function(element, operation, what, url) {
if (what === 'members') {
if (url.indexOf('members') > -1) {
return {
param: element
};
Expand Down
20 changes: 12 additions & 8 deletions app/services/image.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
return service;

function createFileRecord(S3Response) {
return api.one('members', S3Response.userHandle).one('photo').customPUT(JSON.stringify(S3Response.body))
return api.one('members', S3Response.userHandle).customPUT(S3Response.body, 'photo')
.then(function() {
// Show notification that upload was successful
$rootScope.$broadcast(CONSTANTS.EVENT_PROFILE_UPDATED);
Expand All @@ -32,7 +32,7 @@
function getPresignedUrl(userHandle, file) {
var deferred = $q.defer();

api.one('members', userHandle).customPOST(undefined, 'photoUploadUrl', {}, {'Content-Type': file.type})
api.one('members', userHandle).post('photoUploadUrl', {contentType: file.type})
.then(function(response) {
deferred.resolve({
preSignedURL: response.preSignedURL,
Expand All @@ -52,21 +52,25 @@
function uploadFileToS3(response) {
var deferred = $q.defer();
var xhr = new XMLHttpRequest();
var formData = new FormData();
formData.append('userimage', response.file, response.file.name);

xhr.open('PUT', response.preSignedURL, true);
xhr.setRequestHeader('Content-Type', 'multipart/form-data');
xhr.setRequestHeader('Content-Type', response.file.type);

// xhr version of the success callback
xhr.onreadystatechange = function() {
var status = xhr.status;
if (((status >= 200 && status < 300) || status === 304) && xhr.readyState === 4) {
$log.info('Successfully uploaded file')
$log.info('Successfully uploaded file');
deferred.resolve({
userHandle: response.userHandle,
body: { param: { token: response.token } }
body: {
token: response.token,
contentType: response.file.type
}
});
} else if (status >= 400) {
$log.error('Error uploading to S3 with status: ' + status);
deferred.reject(err);
}
};

Expand All @@ -75,7 +79,7 @@
deferred.reject(err);
}

xhr.send(formData);
xhr.send(response.file);

return deferred.promise;
}
Expand Down
2 changes: 1 addition & 1 deletion app/settings/edit-profile/edit-profile.jade
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

.fields
.field-section.edit-image
img.profile-circle(fallback-src="/images/avatarPlaceholder.png", loading-src="/images/avatarPlaceholder.png", ng-src="{{vm.userData.photo.photoUrl}}")
img.profile-circle(fallback-src="/images/avatarPlaceholder.png", ng-src="{{vm.userData.photoURL}}")

.upload-image
p Edit Image
Expand Down
4 changes: 2 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@
"angular-ui-router": "~0.2.15",
"angular-xml": "~2.1.1",
"appirio-tech-ng-iso-constants": "[email protected]:appirio-tech/ng-iso-constants#~1.0.1",
"d3": "~3.5.6",
"devicon": "*",
"fontawesome": "~4.3.0",
"jstzdetect": "~1.0.6",
"moment": "~2.10.3",
"ng-notifications-bar": "~0.0.15",
"ngDialog": "0.5.1",
"restangular": "~1.5.1",
"d3": "~3.5.6"
"restangular": "~1.5.1"
},
"devDependencies": {
"bardjs": "~0.1.4",
Expand Down