Questions tagged [uri]

A Uniform Resource Identifier (or URI) is a string of characters used to identify a name or resource. URI is legacy terminology. In most cases, the term URL should be used instead.

A Uniform Resource Identifier (or URI) is a string of characters used to identify a name or resource.

Note: The current URL Standard at https://url.spec.whatwg.org/#url-representation supersedes RFC 3986 and dispenses with the use of the term URI, as documented in its Goals section:

Standardize on the term URL. URI and IRI are just confusing. In practice a single algorithm is used for both so keeping them distinct is not helping anyone. URL also easily wins the search result popularity contest.

But the information below documents URI in terms of the legacy RFC 3986 spec.


Structure

A URI can be a Uniform Resource Locator , a Uniform Resource Name , or both.

RFC 3986 defines a URI as composed of the following parts:

    foo://example.com:8042/over/there?name=ferret#nose
    \_/   \______________/\_________/ \_________/ \__/
     |           |            |            |        |
  scheme     authority       path        query   fragment

Then defining relative URIs (Section 5.2), you can omit any of those sections, always starting from the left. In pseudo-code, it looks like this:

 result = ""

  if defined(scheme) then
     append scheme to result;
     append ":" to result;
  endif;

  if defined(authority) then
     append "//" to result;
     append authority to result;
  endif;

  append path to result;

  if defined(query) then
     append "?" to result;
     append query to result;
  endif;

  if defined(fragment) then
     append "#" to result;
     append fragment to result;
  endif;

  return result;

The URI you are describing is a scheme-less relative URI.

Examples

For example, in the following URI:

https://stackoverflow.com/questions/tagged/uri?sort=newest&pagesize=50#questions

... the components are:

  • scheme: https

  • hierarchical part: //stackoverflow.com/questions/tagged/uri

  • query: sort=newest&pagesize=50

  • fragment: questions

The precise syntax of the individual components varies depending on the scheme. Here are some examples:

  • mailto:nobody@example.com?subject=Hello&body=Is%20anybody%20home%3F

  • data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=

  • urn:ietf:rfc:3986

URL

A URL is a URI but is more specific. In addition to identifying a web resource, a URL specifies the means of acting upon or obtaining the representation, specifying both its primary access mechanism and network location.

For example, the URL http://example.org/wiki/Main_Page refers to a resource identified as /wiki/Main_Page whose representation, in the form of HTML and related code, obtainable via HyperText Transfer Protocol (http) from a network host whose domain name is example.org.

URI Reference

A URI reference may take the form of a full URI, or just the scheme-specific portion of one, or even some trailing component thereof – even the empty string. An optional fragment identifier, preceded by #, may be present at the end of a URI reference. The part of the reference before the # indirectly identifies a resource, and the fragment identifier identifies some portion of that resource.

To derive a URI from a URI reference, software converts the URI reference to 'absolute' form by merging it with an absolute 'base' URI according to a fixed algorithm. The system treats the URI reference as relative to the base URI, although in the case of an absolute reference, the base has no relevance. The base URI typically identifies the document containing the URI reference, although this can be overridden by declarations made within the document or as part of an external data transmission protocol. If the base URI includes a fragment identifier, it is ignored during the merging process. If a fragment identifier is present in the URI reference, it is preserved during the merging process.

Web document markup languages frequently use URI references to point to other resources, such as external documents or specific portions of the same logical document.

Uses of URI references in markup languages

  • In HTML, the value of the src attribute of the img element provides a URI reference, as does the value of the href attribute of the a or link element.
  • In XML, the system identifier appearing after the SYSTEM keyword in a DTD is a fragmentless URI reference.
  • In XSLT, the value of the href attribute of the xsl:import element/instruction is a URI reference; likewise the first argument to the document() function.

Examples of absolute URIs

Examples of URI references

6139 questions
2
votes
2 answers

Exoplayer not playing local file on local storage

I am trying to play local file in device like this String filePath="/storage/emulated/0/MyFiles/Media/Video/Xvid1509401908940.mp4" File file=new File(filePath); Uri localUri=Uri.fromFile(file); exoPlayer_main.initializePlayer(localUri); Getting…
androidXP
  • 1,692
  • 3
  • 27
  • 58
2
votes
1 answer

How to give assets URI in Yalantis Ucrop

I'm fetching image from my android assets folder and cache. My asset uri is //assets/initial/initialone.jpg while my gallery uri is /data/user/0/packagename/image/image.jpg. I can't give these URI to the Ucrop android library. Below is what I've…
Vimal
  • 197
  • 1
  • 11
2
votes
0 answers

Android 8.0 issue for File share through other app (Email,Whatsapp etc..)

I have .wav files in my internal storage. using my android app I want to share that files using the supported app. ArrayList files = new ArrayList(); Uri uri = Uri.fromFile(file); Intent share = new…
Parth
  • 1,908
  • 1
  • 19
  • 37
2
votes
2 answers

Get Uri from file I just created (android)

forgive me for what is probably a stupid question, but I really can't find the answer anywhere. I need my program to save the contents of an EditText as an html file and share it with other applications. To do this, I need to write the file to…
2
votes
0 answers

Custom URI for android application

I want to call the activity Tap In when an NFC Tag is tapped to my phone using URI Scheme. How can I define this in android manifest?... not to launch an app, but only open content in that app. In data, how is host, path, and scheme defined and how…
2
votes
1 answer

HTTP request with Perl to a utf-8 URI (some non-ascii chars inside) throws a 404 Not Found error

I'm trying to request an URL which has some characters that are non-ASCII, for example: http://perry.wikia.com/wiki/Página_principal which has an á symbol. I've tried with LWP::UserAgent but it throws a 404 Not found error: #!/usr/bin/perl use…
Akronix
  • 1,858
  • 2
  • 19
  • 32
2
votes
2 answers

Multipart Request Using Android Volley (uploading multiple images to server)

This is the gist iam refering for uploading images to the server https://gist.github.com/anggadarkprince/a7c536da091f4b26bb4abf2f92926594 But iam using TedPicker OnMultiImageSelectedListener to select multiple images …
Sooraj S
  • 291
  • 5
  • 13
2
votes
2 answers

Cannot get the file path for the Uri

In my WPF I want images on the screen to change, every time when the user clicks right button. The problem is that I have all the time same error message: 'Invalid URI: The format of the URI could not be determined.' This is the code: string pic1…
milk
  • 23
  • 2
2
votes
0 answers

Encoding query string variables within Uri class

I have a Uri stored in a System.Uri class which contains a query string. If I use Uri.Query the result is ?workarea=Airconaire+Ltd What I need is to be able to extract the Uri variables so that I can Urlencode Airconaire+Ltd to get Airconaire%2bLtd?…
m.edmondson
  • 30,382
  • 27
  • 123
  • 206
2
votes
2 answers

check if a uri is from removable storage

how to check if a Uri user selected from action_open_document tree is got from removable Sd card? i check this but its same for primary sd card and removable sd card! is there any other way? protected void onActivityResult(int requestCode, int…
Mostafa
  • 95
  • 1
  • 10
2
votes
1 answer

How to have URI template with optional variable with path

I am using site prism to create an page object that has a possible 2 urls. Site_prism uses Addressable::Template, and this uses the URI template RFC 6570. The required page contains a list of elements, but can have none as well, and from this logic…
Ben_Slaughter
  • 256
  • 3
  • 10
2
votes
1 answer

C# + UWP: Convert Windowspath to ms-appdata uri

I'm wrting code for a tool which runs on a raspberry pi. That tool should download an HTML-File and open it in a webview. After the download The file is located in this…
k.troy2012
  • 344
  • 4
  • 21
2
votes
0 answers

get uri from gallery xamarin forms

I am working with xamarin.forms and using this code to get an image from user gallery protected async Task PickImage() { try { Stream stream = await DependencyService.Get().GetImageStreamAsync(); …
Joyce de Lanna
  • 1,473
  • 2
  • 15
  • 39
2
votes
2 answers

How to create Uri without fragmentation (convert # to %23)

I am trying to do advanced searches by using the query string but when I include # it doesn't get converted to %23 when creating a uri. var webAddress = "www.worldwideweb.com/abc#d#e"; var uri = new Uri(webAddress).AbsoluteUri; When I do that, an…
2
votes
1 answer

Uri file size is always 0

I'm getting a audio file which I'm saving in a uri (android.net.Uri) I need to display it's size in a TextView. I tried like this: This is where I get the file from users library: @Override protected void onCreate(Bundle savedInstanceState) { …
Daniele
  • 4,163
  • 7
  • 44
  • 95
1 2 3
99
100