I am using the OneDrive JS Picker and would like to get both a download and share value. The sample in the documentation lists the options for the action parameter separated by pipes. I was hoping to use bitwise operators to combine those values (e.g.
action: "share | download"
but that doesn't seem to allow both the webUrl value and the download url (#microsoft.graph.downloadUrl)... has anybody else been able to do this? Or is there a way to use the share URL (webUrl) to get a download url so we can get the text contents of files?
I know there is a REST service available though that may be deprecated, given the message at the top of that page:
This documentation is archived and is not being maintained.
but if that is still usable, perhaps we could use that to download the file... if so, can I put the file id in that download URL and an access token?
I was able to host the OneDrive.js file locally, un-minify it and modify the line below (line 104) to have the downloadUrl included in all queries on files. That allows us to get a shareUrl and a downloadUrl.
e.DEFAULT_QUERY_ITEM_PARAMETER = "expand=thumbnails&select=id,name,size,webUrl,folder,#content.downloadUrl";
sorry for the missleading pipe sign. Actually right now we only allow one action per request like (action: "query"). The pipeline sign in the doc means 'or' in English not in code.
Before my answer, I want to clarify the difference between a webUrl and a shareUrl.
A webUrl which you see in the response's 'webUrl' attribute is the
url pointed to the resource online which requires user login to see
it.
A shareUrl which contains the permission which everyone who has the
link could see/edit it based on the user's config.
JS Picker
If you want the download link and a webUrl back at the same time, it should be easy:
{
action: "query",
advanced: {queryParameters: "select=id,name,webUrl,#content.downloadUrl"}
}
If you want both the download link and share link back at the same time, it is not supported.
API
For using the API to achieve this, you can go to the new API page: https://dev.onedrive.com/items/get.htm
and get the item with already shared links should be
GET /v1.0/drive/items/<item-id>?select=id,name,#content.downloadUrl,webUrl&expand=permissions
all already shared links should be returned in the permissions array object.
If you don't have a shared link, and you need to create the shared link, you should try https://dev.onedrive.com/items/sharing_createLink.htm
while it does not return the webUrl and download url back so you need an extra request.
Related
By custom user links, i mean like for example when a user registers to the website, a page is created specifically for that user with a link.
For Example
https:/domain.com/users/customerName
Then after creating the link, the website will automatically customize the website by using a clone of a specific webpage.
*Btw i've already took Care of the Login/Register part. I just need to know how custom user links would work.
Option 1: example.com/user
Use a single PHP file and an .htaccess file. Check out How to create friendly URL in php?
Option 2: user.example.com
Create sub-domains for each user, also uses .htaccess. Check out How to let PHP to create subdomain automatically for each user?
Option 3: example.com?user=name
Create a single php file and use $_GET parameters. This is the most usual and easiest way to customize the website based on the user who registered and logged in. (usually using user ID number: example.com/profile.php?user=71)
Of course there's also Session handling.
I think you searching for URL rewriting concept.
If user login the page no need to clone the page.you could access the same page with this user data and specification(dynamic page).Many the page content with php functions
URL rewriting
you could the function in .htaccess
if user enters the page
http://example.com/someuser
its rewrite the url with
http://example.com?q=someuser
if you see the url bar its like special page for the user.
It's actually fairly simple. You just use GET within PHP and the URL would be something like http://example.com/user?id=4453623 - If you've ever been on facebook you'll notice they use PHP for the profile pages and much other things too. If you go to your profile page, you'll notice a "id=" variable up in the URL and that's how they determine which profile page to display to you.
This is basically what #Granny commented.
I'm having a problem, or better to say a doubt about how to do.
Let's explain: I have an website similar to a blog where I write articles and they are displayed in the homepage. I want that every time I click on an article it redirects me to the page where the article's content is shown. I save every article in a database with the title, date, content, etc... My doubt is: should I create a .html file for each article or only a file called "article.php" and when I open it, it changes the content getting the data from the database?
Second question: I want that the url of the page changes based of article that I click. For example I click on the article called "Today and Tomorrow", I want that the URL appears as "mysite/today-and-tomorrow/", not "mysite/article.php".
I'm a bit confused about this topic so if anyone can help me i'd be very happy.
Thanks in advice.
I have tried
var link = 'www.example.com/training/product.html';
link.split('.html')[0];
window.history.replaceState( null, null, link );
But it changes the URL dinamically, so for a few seconds it appears the original URL, in my case it appears "mysite/article.php" and then it changes in "mysite/today-and-tomorrow". I don't think it's properly correct.
I also tried
function openArticle(title){
var rightTitle = $(title).text();
rightTitle = rightTitle.toLowerCase();
rightTitle = rightTitle.substring(rightTitle .indexOf(':')+2);
rightTitle = rightTitle.replace(/[^A-Z0-9]+/ig, "-");
event.preventDefault();
window.location.href = title.href + "/" + rightTitle;
}
But when I click on the element the "article.php" remains in the url
should I create a .html file for each article or only a file called "article.php" and when I open it, it changes the content getting the data from the database?
No you dont have to. You can pass article id as a "query string" to "article.php" and it will take care of providing proper article to the end user.
I want that the url of the page changes based of article that I click. For example I click on the article called "Today and Tomorrow", I want that the URL appears as "mysite/today-and-tomorrow/", not "mysite/article.php".
You are talking about a feature called "URL Rewriting" which produces nice & meaningful URLs. In order to implement it you need to:
Design your database in a way which it can map articles id to its title.(for creating alias)
You have to enable URL Rewrite in your web server. (for example if you are using Apache as web server, you need to enable mod_rewrite).
You have to embed your rules for mapping & routing nice URLs to the original ones in a file called .htaccess. as a sample How to write htaccess rewrite rule for seo friendly url
I was just trying to help you get an overall idea of what you are looking for from technical point of view & as you know Its impossible to cover your required information in just a single post.
I have a PDF that has a button with field name ctaButton.
ctaButton currently has a url pointing to https://mywebsite.com.
I want to host the PDF on my server at https://mywebsite.com/hosted.pdf.
And when I send someone a link to the PDF, I want to attach a UTM_term parameter ?utm_term=customer1 and then have the PDF read this parameter and update the ctaButton url to https://mywebsite.com/?utm_term=customer1.
I've been messing around with the Javascript actions in Acrobat for a couple of hours trying to make this happen. Any help greatly appreciated.
You can get the full url to the document using...
var myURL = this.url;
"this" in Acrobat JavaScript is the document context.
I did hours of research and came to this conclusion – Javascript in Acrobat is like trying to code in 1985 AND browsers will not execute whatever code you come up with.
So I used this workaround:
When I send the PDF to someone, I send it as a link with a base64
encoded stringified JSON package that contains a bunch of tracking
data but importantly, the name of the file to access as well as utm
parameters specific to the recipient
The link hits a server handler (NodeJS) that extracts the encoded
JSON package, and uses the data in the package to serve up an HTML
redirect page pointing to the right PDF file
Importantly, the HTML page also saves the JSON package to the
browser's localStorage . . . this comes in handy in subsequent
steps
The PDF file opens in browser (it doesn't have to, could be opened on
desktop) and the call to action link has a link to a get request
handler
The get request handler serves up ANOTHER redirect page
This second redirect page accesses the browser's local storage, looks
for the utm parameters I set for that user, and then redirects to the
sale page, with nice utm parameters attached
So to sum up, you don't add the utm parameters to the call to action link in the PDF (because that would make the world too easy to live in) and instead you do all these acrobatics (no pun intended) to attach utm parameters in the link clicks (via JSON strings saved in localStorage) during the process (i.e. when user opens email to extract file via link, and then when user clicks call to action in the PDF).
Any questions or clarifications please let me know in the comments and I will do my best to address.
Caveats
Only works if user uses same browser in all steps (i.e. if Susan opens the email in Safari, saves the PDF, then clicks the call to action in the PDF, and the link opens in Chrome, utm parameters will not be passed).
Assumes browser is modern and has localStorage
UPDATE: I came across another solution. It's a bit more convoluted. Diagram below.
Porky.io is a Javascript extension for Adobe Indesign. So flow is:
send Porky.io the customer data you need (e.g. utm's for links)
Porky.io generates PDF from a template you provide with the customer data you provided
Listen for a new file save from Porky
Do something with the file (e.g. email it to customer)
I believe you need to run an instance of Windows somewhere in the cloud (e.g. on Azure) to run Indesign with the Porky.io. Unless you want to rely on your laptop.
My project's not big enough yet to warrant setting this up . . . but good alternative if I need to make my current solution more robust.
You would think my problem would be so commonplace that there would be solutions all over the internet for it. But I can't find anything that really answers my question.
Let me summarise my situation:
I am using Open UI5.
I am coding an app which retrieves documents from various external websites. I want to display these documents inside my app, and not navigate to them, so I display the documents in an iframe. Haven't found any other way.
Some filetypes can be displayed natively, such as PDFs. Others, like Word, cannot - the easiest way I have found of displaying these is by using Google Docs, which implies changing the URL of the iframe's src from this :
http://example.com/my-target-doc.docx
to this:
http://docs.google.com/gview?url=example.com/my-target-doc.docx&embedded=true
Some of the external domains I retrieve the documents from require authentication. Therefore, I cannot set the iframe's src to http://docs.google.com/gview?url=example.com/my-target-doc.docx&embedded=true directly - Google docs would attempt to display the authentication page. I must keep the original URL, and then, once the user's authenticated, replace the document URL with the Google docs version of the same URL.
What I am trying to do, then, is use the iframe's "onload" event to get the currently loaded page's address and, if it is a .doc/.docx/.ppt etc, replace that same URL with the GD version of the URL.
The difficulty is that there is no extension at the end of the URL which points to the document - none of the URLs I need to use end with ".doc", ".ppt" or whatever, so parsing the URL is out.
So this is my question : Is there a way in Javascript to get the type of the content being returned? To be fair, I am pretty doubtful there is. Other ideas or alternatives are welcome. I am still actively looking for some.
Thanks!
Did you already look at the Content-type HTTP header? This can be read with JS, but you probably have to request the file asynchronously for that.
Is it possible to use jQuery to find the current url's filename (path) when a default document (or possibly mvc routing) is used and there is no filename in the address bar?
I am using jQuery to build a navigation system and I have it comparing the current URL to each nav item to determine if it is the selected item. I've seen a lot of answers about getting file info, but I haven't been able to get a difinitive answer if this is able to be done when there is no filename showing.
EXAMPLE: "www.mysite.com" -- this url/page could be: index.html, default.aspx, default.asp, index.htm, etc.
This is needed so I can see what nav link should be highlighted on the default page. Thanks.
The information is just not available at all, jQuery or no jQuery. The site responds however it wants. Some might do an explicit redirect, I guess, but it's pretty hard (if possible at all) to track that client-side.
Of course, if you control the server, then your server can obviously instrument the outgoing pages however it wants.