You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
i've got a little problem. I want to upload a file via a form to my google cloud bucket.
With the file_input function from the Phoenix.HTML.Form module i receive an upload plug like this:
I use the filename and the path as input for my upload function:
def upload_image(file_path, file_name) do
# Authenticate.
{:ok, token} = Goth.Token.for_scope("https://www.googleapis.com/auth/cloud-platform")
conn = GoogleApi.Storage.V1.Connection.new(token.token)
bucket_id = System.get_env("GOOGLE_PROJECT_ID")
file_uuid = UUID.uuid4(:hex)
unique_filename = "#{file_uuid}-#{file_name}"
# Make the API request.
GoogleApi.Storage.V1.Api.Objects.storage_objects_insert_simple(
conn,
bucket_id,
"multipart",
%{name: unique_filename},
image_binary
)
end
But when the upload_image function get's triggered, my application runs into a timeout.
The error from my test is also not very informative...
** (ExUnit.TimeoutError) test timed out after 60000ms. You can change the timeout:
1. per test by setting "@tag timeout: x"
2. per case by setting "@moduletag timeout: x"
3. globally via "ExUnit.start(timeout: x)" configuration
4. or set it to infinity per run by calling "mix test --trace"
(useful when using IEx.pry)
Timeouts are given as integers in milliseconds.
code: Erlebe.Uploader.Google.upload_image(
stacktrace:
(inets) httpc.erl:626: :httpc.handle_answer/3
(inets) httpc.erl:567: :httpc.handle_request/9
(tesla) lib/tesla/adapter/httpc.ex:32: Tesla.Adapter.Httpc.request/2
(tesla) lib/tesla/adapter/httpc.ex:19: Tesla.Adapter.Httpc.call/2
(tesla) lib/tesla/middleware/core.ex:6: Tesla.Middleware.Normalize.call/3
(google_api_storage) lib/google_api/storage/v1/api/objects.ex:559: GoogleApi.Storage.V1.Api.Objects.storage_objects_insert_simple/6
test/erlebe/uploader/google_test.exs:21: (test)
(ex_unit) lib/ex_unit/runner.ex:312: ExUnit.Runner.exec_test/1
(stdlib) timer.erl:166: :timer.tc/1
(ex_unit) lib/ex_unit/runner.ex:251: anonymous fn/4 in ExUnit.Runner.spawn_test/3
I really hope someone can help me with my issue!
Thanks in advance,
Felix
The text was updated successfully, but these errors were encountered:
Hello,
i've got a little problem. I want to upload a file via a form to my google cloud bucket.
With the
file_input
function from thePhoenix.HTML.Form
module i receive an upload plug like this:I use the
filename
and thepath
as input for my upload function:But when the
upload_image
function get's triggered, my application runs into a timeout.The error from my test is also not very informative...
I really hope someone can help me with my issue!
Thanks in advance,
Felix
The text was updated successfully, but these errors were encountered: