Object Storage: Download object and write to file #918

Open
lsarni opened this Issue Jan 11, 2017 · 7 comments

Projects

None yet

2 participants

@lsarni
lsarni commented Jan 11, 2017 edited

I'm using this to download an object and write it to a file:
client.objectStorage().objects().download(publicBucket, externalFileName).writeToFile(new File(localFile));

I was expecting it to fail with a StorageException if the object didn't exist but this is not the case, it creates a file of 70 bytes.
Is this the expected outcome? I was expecting the http response to be not found and that to be in the storage exception.

@auhlig
Member
auhlig commented Jan 11, 2017 edited

Mh. At first glance no. It's unexpected. Could you check the response from Swift, @lsarni ?

@lsarni
lsarni commented Jan 12, 2017

Using this I get:

HTTP/1.1 404 Not Found
Content-Length: 70
Content-Type: text/html; charset=UTF-8
X-Trans-Id: tx0b057418fd4d4de2aac6c-0058777297
Date: Thu, 12 Jan 2017 12:12:07 GMT

<html><h1>Not Found</h1><p>The resource could not be found.</p></html>

I also tried it on a console app, outside my main project, and it still downloads a file.

@auhlig
Member
auhlig commented Jan 12, 2017 edited

Looking at the content length, I guess the response is written to the file?

@lsarni
lsarni commented Jan 12, 2017 edited

Yes, I was trying to download an image but if I download a txt the content is:

<html><h1>Not Found</h1><p>The resource could not be found.</p></html>

@auhlig
Member
auhlig commented Jan 12, 2017 edited

Mh. It should return null, as the download() method leads to get(), looking at https://github.com/ContainX/openstack4j/blob/master/core/src/main/java/org/openstack4j/openstack/storage/object/internal/ObjectStorageObjectServiceImpl.java#L82 .
What happens if you just try to download? Whiteout writing to file)
I guess you found a bug if that's not working.

@lsarni
lsarni commented Jan 13, 2017

If I download without writing to the file it doesn't fail either, it returns a DLPayload that has an HttpResponse saying 404 Not Found.

@auhlig
Member
auhlig commented Jan 13, 2017 edited

Ok. I'll mark it as a bug.
Since you're already familiar with the issue, would you like to contribute and fix it @lsarni?
Would be much appreciated.

@auhlig auhlig added the bug label Jan 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment