You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jclouds.apache.org by Yuva raj <uv...@gmail.com> on 2013/08/22 12:54:39 UTC

Fwd: How to get URL of a blob after Uploading to swift

Hello all,

I am using jclouds to talk with openstack swift and keystone. Using the
context builder i am able to authenticate with keystone.

How can i get the public URL of the object-store from the context ?

After uploading a blob how can i get swift URL of the uploaded blob?
So that i can store it in my application database to use it in the future.
-- 
*Thanks*

*Yuvaraj L*



-- 
*Thanks*

*Yuvaraj L*

Re: Fwd: How to get URL of a blob after Uploading to swift

Posted by Andrew Gaul <ga...@apache.org>.
Kevin, I tested and confirmed that atmos, aws-s3, and azure use headers
to authenticate and cloudfiles-us and hpcloud-objectstorage use query
string parameters.  Can you file a JIRA issue for the lack of support
for aws-s3?  Also, would you like to try patching this and sending
jclouds a pull request?  This feature only requires small changes to
AWSS3BlobRequestSigner and if you drop by #jclouds on irc.freenode.net I
would be happy to help you.

On Sat, Aug 24, 2013 at 03:09:48PM -0700, Kevin Krouse wrote:
> I haven't tried other providers yet, but at least for the S3 provider
> it looks like the URL from .signGetBlob() doesn't include the query
> parameters specific for that provider and uses the Authorization
> header instead.
> 
> Kevin
> 
> 
> On Fri, Aug 23, 2013 at 9:01 PM, Andrew Gaul <ga...@apache.org> wrote:
> > Kevin, this is exactly what a signed URL means.  I can vouch that
> > jclouds supports this for Atmos, Azure, S3, and Swift.  Note that some
> > providers give additional features in their signed URL mechanism such as
> > time-limited and byte-range requests although jclouds does not yet
> > expose these.
> >
> > On Fri, Aug 23, 2013 at 02:16:11PM -0700, Kevin Krouse wrote:
> >> Is there a helper to get a signed URL that uses query string
> >> parameters instead of the Authorization header?
> >>
> >> Something like this:
> >>
> >> http://docs.aws.amazon.com/AmazonS3/latest/dev/RESTAuthentication.html#RESTAuthenticationQueryStringAuth
> >> http://msdn.microsoft.com/en-us/library/dn140256.aspx
> >>
> >> Kevin
> >>
> >>
> >> On Thu, Aug 22, 2013 at 9:11 AM, Andrew Gaul <ga...@apache.org> wrote:
> >> > On Thu, Aug 22, 2013 at 02:50:25PM +0200, Andrew Phillips wrote:
> >> >> Have a look at the Rackspace examples [1]. Specifically, CloudFilesPublish
> >> >> and GenerateTempURL could help. One of the cloud-storage-workshop exercises
> >> >> [2] also has an example that might be useful.
> >> >
> >> > You can also use BlobRequestSigner.signGetBlob which embeds per-blob
> >> > authentication and allows you to express a time-bound for some
> >> > providers, including Swift.
> >> >
> >> > --
> >> > Andrew Gaul
> >> > http://gaul.org/
> >
> > --
> > Andrew Gaul
> > http://gaul.org/

-- 
Andrew Gaul
http://gaul.org/

Re: Fwd: How to get URL of a blob after Uploading to swift

Posted by Kevin Krouse <ke...@gmail.com>.
I haven't tried other providers yet, but at least for the S3 provider
it looks like the URL from .signGetBlob() doesn't include the query
parameters specific for that provider and uses the Authorization
header instead.

Kevin


On Fri, Aug 23, 2013 at 9:01 PM, Andrew Gaul <ga...@apache.org> wrote:
> Kevin, this is exactly what a signed URL means.  I can vouch that
> jclouds supports this for Atmos, Azure, S3, and Swift.  Note that some
> providers give additional features in their signed URL mechanism such as
> time-limited and byte-range requests although jclouds does not yet
> expose these.
>
> On Fri, Aug 23, 2013 at 02:16:11PM -0700, Kevin Krouse wrote:
>> Is there a helper to get a signed URL that uses query string
>> parameters instead of the Authorization header?
>>
>> Something like this:
>>
>> http://docs.aws.amazon.com/AmazonS3/latest/dev/RESTAuthentication.html#RESTAuthenticationQueryStringAuth
>> http://msdn.microsoft.com/en-us/library/dn140256.aspx
>>
>> Kevin
>>
>>
>> On Thu, Aug 22, 2013 at 9:11 AM, Andrew Gaul <ga...@apache.org> wrote:
>> > On Thu, Aug 22, 2013 at 02:50:25PM +0200, Andrew Phillips wrote:
>> >> Have a look at the Rackspace examples [1]. Specifically, CloudFilesPublish
>> >> and GenerateTempURL could help. One of the cloud-storage-workshop exercises
>> >> [2] also has an example that might be useful.
>> >
>> > You can also use BlobRequestSigner.signGetBlob which embeds per-blob
>> > authentication and allows you to express a time-bound for some
>> > providers, including Swift.
>> >
>> > --
>> > Andrew Gaul
>> > http://gaul.org/
>
> --
> Andrew Gaul
> http://gaul.org/

Re: Fwd: How to get URL of a blob after Uploading to swift

Posted by Andrew Gaul <ga...@apache.org>.
Kevin, this is exactly what a signed URL means.  I can vouch that
jclouds supports this for Atmos, Azure, S3, and Swift.  Note that some
providers give additional features in their signed URL mechanism such as
time-limited and byte-range requests although jclouds does not yet
expose these.

On Fri, Aug 23, 2013 at 02:16:11PM -0700, Kevin Krouse wrote:
> Is there a helper to get a signed URL that uses query string
> parameters instead of the Authorization header?
> 
> Something like this:
> 
> http://docs.aws.amazon.com/AmazonS3/latest/dev/RESTAuthentication.html#RESTAuthenticationQueryStringAuth
> http://msdn.microsoft.com/en-us/library/dn140256.aspx
> 
> Kevin
> 
> 
> On Thu, Aug 22, 2013 at 9:11 AM, Andrew Gaul <ga...@apache.org> wrote:
> > On Thu, Aug 22, 2013 at 02:50:25PM +0200, Andrew Phillips wrote:
> >> Have a look at the Rackspace examples [1]. Specifically, CloudFilesPublish
> >> and GenerateTempURL could help. One of the cloud-storage-workshop exercises
> >> [2] also has an example that might be useful.
> >
> > You can also use BlobRequestSigner.signGetBlob which embeds per-blob
> > authentication and allows you to express a time-bound for some
> > providers, including Swift.
> >
> > --
> > Andrew Gaul
> > http://gaul.org/

-- 
Andrew Gaul
http://gaul.org/

Re: Fwd: How to get URL of a blob after Uploading to swift

Posted by Andrew Phillips <an...@apache.org>.
> Am I going about this wrong?  Would you recommend a different approach?

No, what you're doing seems fine for your use case. As Andrew Gaul  
pointed out, the SwiftBlobSigner [1] looks like what you want,  
specifically the versions that accept a timeout parameter.

If you have a look at the getBlobWithTime test [2, 3], you'll see that  
the expected result URL, which should work without requiring any  
headers to be set.

You could also try running the testSignGetUrlWithTime live test [4, 5]  
with wire and header logging turned up, to see what requests are made.

Regards

ap

[1]  
https://github.com/jclouds/jclouds/blob/master/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftBlobSigner.java
[2]  
https://github.com/jclouds/jclouds/blob/master/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/SwiftBlobSignerExpectTest.java#L61
[3]  
https://github.com/jclouds/jclouds/blob/master/blobstore/src/test/java/org/jclouds/blobstore/internal/BaseBlobSignerExpectTest.java#L65
[4]  
https://github.com/jclouds/jclouds/blob/master/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftBlobSignerLiveTest.java
[5]  
https://github.com/jclouds/jclouds/blob/master/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobSignerLiveTest.java#L79

Re: Fwd: How to get URL of a blob after Uploading to swift

Posted by Kevin Krouse <ke...@gmail.com>.
Yes, that's correct.  I'm writing a server app that exposes the cloud
container via webdav.  In this particular case, the client is an
in-browser webdav file browser written in javascript.  I do have
control of the js webdav client, but I was hoping to redirect the
browser client to a signed url in order to download the blob for a
webdav GET.  Alternatively, the webdav resource url could just be the
signed url.  Proxying through my server app also works, but it would
be preferable to download directly from the provider.

Eventually, there will be an applet or other webdav client to perform
the multi-part uploads for large files.  That client app would also
need to use the signed urls, I would imagine.

Am I going about this wrong?  Would you recommend a different approach?

Kevin


On Fri, Aug 23, 2013 at 5:22 PM, Andrew Phillips <an...@apache.org> wrote:
>> I was hoping to return a 302 or 307 redirect the browser to the
>> appropriate endpoint.  The Auth header isn't included in the redirect,
>> so query parameters are required instead.
>
>
> Just to clarify: you're writing a *server-side* app and are trying so send
> *clients* to a different URL which is pre-signed? Do you have control of the
> client app in any way?
>
> ap

Re: Fwd: How to get URL of a blob after Uploading to swift

Posted by Andrew Phillips <an...@apache.org>.
> I was hoping to return a 302 or 307 redirect the browser to the
> appropriate endpoint.  The Auth header isn't included in the redirect,
> so query parameters are required instead.

Just to clarify: you're writing a *server-side* app and are trying so  
send *clients* to a different URL which is pre-signed? Do you have  
control of the client app in any way?

ap

Re: Fwd: How to get URL of a blob after Uploading to swift

Posted by Kevin Krouse <ke...@gmail.com>.
I was hoping to return a 302 or 307 redirect the browser to the
appropriate endpoint.  The Auth header isn't included in the redirect,
so query parameters are required instead.

I'm new to the cloud -- how are others handling authentication on the client?

Kevin


On Fri, Aug 23, 2013 at 2:46 PM, Andrew Phillips <an...@apache.org> wrote:
>> Is there a helper to get a signed URL that uses query string
>> parameters instead of the Authorization header?
>
>
> As far as I know (one of the OpenStack gurus may correct me), Swift does not
> support this via query params. What would you expect the "helper" to do -
> transparently rewrite query params to the appropriate header on-the-fly?
>
> Is there any reason you can't transmit a header in your particular case?
>
> ap

Re: Fwd: How to get URL of a blob after Uploading to swift

Posted by Andrew Phillips <an...@apache.org>.
> Is there a helper to get a signed URL that uses query string
> parameters instead of the Authorization header?

As far as I know (one of the OpenStack gurus may correct me), Swift  
does not support this via query params. What would you expect the  
"helper" to do - transparently rewrite query params to the appropriate  
header on-the-fly?

Is there any reason you can't transmit a header in your particular case?

ap

Re: Fwd: How to get URL of a blob after Uploading to swift

Posted by Kevin Krouse <ke...@gmail.com>.
Is there a helper to get a signed URL that uses query string
parameters instead of the Authorization header?

Something like this:

http://docs.aws.amazon.com/AmazonS3/latest/dev/RESTAuthentication.html#RESTAuthenticationQueryStringAuth
http://msdn.microsoft.com/en-us/library/dn140256.aspx

Kevin


On Thu, Aug 22, 2013 at 9:11 AM, Andrew Gaul <ga...@apache.org> wrote:
> On Thu, Aug 22, 2013 at 02:50:25PM +0200, Andrew Phillips wrote:
>> Have a look at the Rackspace examples [1]. Specifically, CloudFilesPublish
>> and GenerateTempURL could help. One of the cloud-storage-workshop exercises
>> [2] also has an example that might be useful.
>
> You can also use BlobRequestSigner.signGetBlob which embeds per-blob
> authentication and allows you to express a time-bound for some
> providers, including Swift.
>
> --
> Andrew Gaul
> http://gaul.org/

Re: Fwd: How to get URL of a blob after Uploading to swift

Posted by Andrew Gaul <ga...@apache.org>.
On Thu, Aug 22, 2013 at 02:50:25PM +0200, Andrew Phillips wrote:
> Have a look at the Rackspace examples [1]. Specifically, CloudFilesPublish
> and GenerateTempURL could help. One of the cloud-storage-workshop exercises
> [2] also has an example that might be useful.

You can also use BlobRequestSigner.signGetBlob which embeds per-blob
authentication and allows you to express a time-bound for some
providers, including Swift.

-- 
Andrew Gaul
http://gaul.org/

Re: Fwd: How to get URL of a blob after Uploading to swift

Posted by Yuva raj <uv...@gmail.com>.
Thanks Andrew :)
That solved  both the questions.


On Thu, Aug 22, 2013 at 6:20 PM, Andrew Phillips <an...@apache.org> wrote:

> Hi Yuvaraj
>
> Have a look at the Rackspace examples [1]. Specifically, CloudFilesPublish
> and GenerateTempURL could help. One of the cloud-storage-workshop exercises
> [2] also has an example that might be useful.
>
> Regards
>
> ap
>
> [1] https://github.com/jclouds/**jclouds-examples/tree/master/**
> rackspace/src/main/java/org/**jclouds/examples/rackspace/**cloudfiles<https://github.com/jclouds/jclouds-examples/tree/master/rackspace/src/main/java/org/jclouds/examples/rackspace/cloudfiles>
> [2] https://github.com/jclouds/**jclouds-cloud-storage-**
> workshop/blob/master/**exercise1/src/main/java/org/**
> jclouds/labs/blobstore/**exercise1/ImageUploader.java#**L69<https://github.com/jclouds/jclouds-cloud-storage-workshop/blob/master/exercise1/src/main/java/org/jclouds/labs/blobstore/exercise1/ImageUploader.java#L69>
>



-- 
*Thanks*

*Yuvaraj L*

Re: Fwd: How to get URL of a blob after Uploading to swift

Posted by Andrew Phillips <an...@apache.org>.
Hi Yuvaraj

Have a look at the Rackspace examples [1]. Specifically,  
CloudFilesPublish and GenerateTempURL could help. One of the  
cloud-storage-workshop exercises [2] also has an example that might be  
useful.

Regards

ap

[1]  
https://github.com/jclouds/jclouds-examples/tree/master/rackspace/src/main/java/org/jclouds/examples/rackspace/cloudfiles
[2]  
https://github.com/jclouds/jclouds-cloud-storage-workshop/blob/master/exercise1/src/main/java/org/jclouds/labs/blobstore/exercise1/ImageUploader.java#L69