• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mirego / accent / #755

04 Apr 2024 05:07PM UTC coverage: 76.689% (-0.08%) from 76.768%
#755

push

github

simonprev
Fix aws us-east-1 subdomain and fix slow projects list

0 of 4 new or added lines in 1 file covered. (0.0%)

2214 of 2887 relevant lines covered (76.69%)

14.69 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/lib/accent/integrations/execute/aws_s3.ex
1
defmodule Accent.IntegrationManager.Execute.AWSS3 do
2
  @moduledoc false
3

4
  alias Accent.Hook
5

6
  def upload_translations(integration, user, params) do
7
    {uploads, version_tag} = Accent.IntegrationManager.Execute.UploadDocuments.all(integration, params)
×
8

9
    # To support bucket with '.' in the name, we need to use the region subdomain.
10
    # The us-east-1 subdomain is not s3-us-east-1. It’s s3 only.
NEW
11
    base_url =
×
NEW
12
      case integration.data.aws_s3_region do
×
NEW
13
        "us-east-1" -> "https://s3.amazonaws.com/#{integration.data.aws_s3_bucket}"
×
NEW
14
        region -> "https://s3-#{region}.amazonaws.com/#{integration.data.aws_s3_bucket}"
×
15
      end
16

17
    url =
×
18
      Path.join([
19
        base_url,
20
        integration.data.aws_s3_path_prefix
×
21
      ])
22

23
    uri = URI.parse(url)
×
24

25
    document_urls =
×
26
      for upload <- uploads do
27
        {url, document_name} = Accent.IntegrationManager.Execute.UploadDocuments.url(upload, uri, version_tag)
×
28

29
        headers =
×
30
          :aws_signature.sign_v4(
31
            integration.data.aws_s3_access_key_id,
×
32
            integration.data.aws_s3_secret_access_key,
×
33
            integration.data.aws_s3_region,
×
34
            "s3",
35
            :calendar.universal_time(),
36
            "put",
37
            url,
38
            [{"host", uri.authority}],
×
39
            upload.render,
×
40
            uri_encode_path: false
41
          )
42

43
        {:ok, %{status_code: 200}} = HTTPoison.put(url, {:file, upload.file}, headers)
×
44

45
        %{name: document_name, url: url}
×
46
      end
47

48
    Hook.outbound(%Hook.Context{
×
49
      event: "integration_execute_azure_storage_container",
50
      project_id: integration.project_id,
×
51
      user_id: user.id,
×
52
      payload: %{
53
        version_tag: version_tag,
54
        document_urls: document_urls
55
      }
56
    })
57

58
    :ok
59
  end
60
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc