dkataskin / erlazure

Windows Azure Erlang bindings
BSD 3-Clause "New" or "Revised" License
35 stars 53 forks source link

time out on small files #19

Closed benjamin79 closed 8 years ago

benjamin79 commented 8 years ago

Hi,

thanks for creating erlazure.

I can list and create containers, but even on 1kb files i get time out when i try to upload something. :erlazure.put_block_blob(pid, 'test', 'x.pdf', File.read!("x.pdf"))

Please help me. I use elixir 1.2.4 with erlang 18.3

taktran commented 8 years ago

Did you end up resolving it @benjamin79 ? I'm getting the same issue

dkataskin commented 8 years ago

@taktran can you give me a sample file?

taktran commented 8 years ago

I just used any image eg, https://www.photobox.co.uk/my/photo/full?photo_id=9213091927

dkataskin commented 8 years ago

I will look into.

taktran commented 8 years ago

Thanks!

taktran commented 8 years ago

I found the 🐛 - it's when Content-Type is undefined, it seems like azure just times out. I found it by displaying Headers1 with erlang:display(Headers1) above the Response = ... line (https://github.com/dkataskin/erlazure/blob/master/src/erlazure.erl#L726)

[{"x-ms-date","Tue, 14 Jun 2016 17:27:28 GMT"},{"x-ms-version","2014-02-14"},{"Host","..."},{"Content-Type",undefined},{"Content-Length","390601"},{"x-ms-blob-type","BlockBlob"}]

When, I hard code image/jpeg for the Content-Type in the source code, and it worked straight away:

[{"x-ms-date","Tue, 14 Jun 2016 17:29:44 GMT"},{"x-ms-version","2014-02-14"},{"Host","..."},{"Content-Type","image/jpeg"},{"Content-Length","390601"},{"x-ms-blob-type","BlockBlob"}]

Not sure if you can extract the content type from the blob, or you need to pass it in as a parameter.

dkataskin commented 8 years ago

Thanks for the insight, the code supposed to set content type to "application/octet-stream" if content_type option is not specified here https://github.com/dkataskin/erlazure/blob/237a7a9c6bc597fe320d693c4a3490b1751dbe81/src/erlazure.erl#L523. I will look if I missed something.

You should be able to set content type to the desired value explicitly by adding {content_type, "your-content-type"} to the list of options.

dkataskin commented 8 years ago

https://github.com/dkataskin/erlazure/commit/22ec00544ea94cd432363d5d3e23266c21e9fe7c commit should have fixed the issue @taktran @benjamin79, @taktran thanks for the insight!

taktran commented 8 years ago

Was just about to say undefined looked like the culprit! Thanks @dkataskin for the speedy response!

taktran commented 8 years ago

Have tried it on my code, and works a charm now. Again, thanks a bunch!