kartike
1 Nickel

How to get the URL of uploaded file

Hi

I need to get the url of uploaded file by using .NET. Just click that url to download the file from the cloud server.

Please let me know the solution.

Regards,

Karthik.

Labels (1)
0 Kudos
9 Replies
JasonCwik
2 Iron

Re: How to get the URL of uploaded file

kartike wrote:

Hi

I need to get the url of uploaded file by using .NET. Just click that url to download the file from the cloud server.

Please let me know the solution.

Regards,

Karthik.

Karthik,

You want "GetShareableUrl" from EsuApi.  You provide the Identifier (either an ObjectId or ObjectPath) and an expiration date for the URL, e.g.

            DateTime expiration = DateTime.UtcNow;

            expiration += TimeSpan.FromHours(5);

            Uri u = esu.GetShareableUrl(id, expiration);

0 Kudos
kartike
1 Nickel

Re: How to get the URL of uploaded file

Hi

I can download the files from url get by getSharableUrl method.

But the url not contains the exact path where i moved the files.

For example,

i moved the file into the following locaition into cloud,

            string filePath= "C://Users//karthike//Desktop//Element.docx";

            ObjectPath objectpath = new ObjectPath("Support/" + productName + "/" + incidentId + "/" + fileName);          
            objectId = upload.CreateObjectOnPath(objectpath, filePath, null, null);

            url = cloudRest.getShareableUrl(objectId, DateTime.MaxValue);

i need the url to download it looks,

http://................................................/Support/ productName/incidentId/fileName.

How can i get the url like above format?

Please Can you give me a solution?

Regards,

Karthik.

0 Kudos
rbala1
2 Iron

Re: How to get the URL of uploaded file

Karthik,

Instead of passing in the ObjectId to getShareableUrl pass in the ObjectPath.  That will return a pre-signed URL to the object in the namespace (the path to the object).

Raj

0 Kudos
kartike
1 Nickel

Re: How to get the URL of uploaded file

Hi,

I can get the url using objectpath.

URL contains userid,expired date value and signature.why signature has different value for each files?

url is like this:

"https://cloudonestorage.peer1.com/rest/namespace/Support/DirectTrac/66666/Element.docx
?uid=value&expires=253402300800&signature=value"

i need to use the url like this,

"https://cloudonestorage.peer1.com/rest/namespace/Support/DirectTrac/66666/Element.docx"

when i click this url i have to redirect to the original link.

how can i redirect to original url?

Regards,

Karthik.

0 Kudos
rbala1
2 Iron

Re: How to get the URL of uploaded file

Karthik,

The signature changes with each request for the same file when the timestamp changes between requests.  The timestamp is used in calculation of the hash.

You won't be able to get the URL in the precise format that you need.  Our shareable URL must contain the UID, signature, and expiration.  Those attributes are required for Atmos to validate the authenticity of the request.

Raj

0 Kudos
kartike
1 Nickel

Re: How to get the URL of uploaded file

Hi bala,

When i click the below url,

https://cloudonestorage.peer1.com/rest/namespace/Support/DirectTrac/66666/Element.docx

It should redirect to following url,

https://cloudonestorage.peer1.com/rest/namespace/Support/DirectTrac/66666/Element.docx
?uid=value&expires=253402300800&signature=value

Is this possible? If yes,Can you please give me a solution?

Regards,

Karthik

0 Kudos
kartike
1 Nickel

Re: How to get the URL of uploaded file

Hi,

Please can anyone answer to my previous question?

Regards,

Karthik.

0 Kudos
Highlighted
JasonCwik
2 Iron

Re: How to get the URL of uploaded file

Hi Karthik,

For security reasons, every URL request must be signed.  The "Shareable URL" feature embeds the signature information as URL parameters.  There currently is no way to authorize direct access to an object without a valid signature.  You will have to generate a shareable URL that expries many years into the future and distribute that link if you want public access to an object.

rbala1
2 Iron

Re: How to get the URL of uploaded file

Just to clarify:

The signature will only change when the expiration changes between requests.

So in this example:

Uri u = esu.GetShareableUrl(id, expiration);

If the expiration does not change the signature will not change.


Raj

0 Kudos