TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Hari Murugesan
NA
39
3.3k
sharepoint profile image not displayed
May 31 2018 2:13 AM
Hi Guys i'm new in ionic with sharepoint
I have developed a Mobile app using ionic3 with sharepoint.
Now i have to get user profile picture in my app.
I have tried these are the way can't achieve here is my tried code.
First way tried like this
abc.sharepoint.com/sites/qa/_layouts/15/userphoto.aspx?size="s"&accountname="
[email protected]
"
Second way tried like this
These url iam geting using people picker result. PictureURL property
https://abc.sharepoint.com/User Photos/ProfilePictures/abc_onmicrosoft_com_MThumb.jpg", "Muthu.jpeg"
These Second method always return
401 UNAUTHORIZED
Above url using to call this method.
public
downloadFile(url:
string
, fileName:
string
) {
let options =
this
._apiHeaderForImageURL();
this
._http.
get
(url, options)
.subscribe((data) => {
//here converting a blob to base 64 For internal view purpose in image src
var reader =
new
FileReader();
reader.readAsDataURL(data.blob());
reader.onloadend = function () {
console.log(
"Base64"
, reader.result);
}
//Here Writing a blob file to storage
this
.file.writeFile(
this
.file.externalRootDirectory, fileName, data.blob(), { replace:
true
})
.then((success) => {
console.log(
"File Writed Successfully"
, success);
}).
catch
((err) => {
console.log(
"Error While Wrinting File"
, err);
});
});
}
public
_apiHeaderForImageURL() {
let headers =
new
Headers({
'Content-Type'
:
'image/jpeg'
});
headers.append(
'Authorization'
,
'Bearer '
+ localStorage.getItem(
"token"
));
let options =
new
RequestOptions({ headers: headers, responseType: 3 });
return
options;
}
The first
api
call worked fine result also
sucess
but image not displayed properly.
Thats
the problem
i'm
facing.
The result
comes an default
image like this only.
pls
help me to achieve this. Any help warmly accepted.
Iam
doing long time stuff to achieve this still
i
cant achieve pls give some idea.
Is any other way is available to get user picture in ionic 3 using
spfx
?
Reply
Answers (
6
)
Sharepoint profile image download in ionic mobile app
"how to check deleted sub sites" in SharePoint