-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename the project because it will have more responsibilities.
- Loading branch information
Burgy Benjamin
committed
Dec 16, 2023
1 parent
62a67cf
commit f3bd838
Showing
28 changed files
with
118 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
version: '3' | ||
services: | ||
kdrive-bridge: | ||
ksuite-middleware: | ||
build: . | ||
image: minidfx/kdrive-bridge:v0.3.0 | ||
image: minidfx/ksuite-middleware:v0.4.0 | ||
environment: | ||
- SECRET_KEY_BASE=<secret> | ||
- PHX_HOST=<host> | ||
- PORT=<port> | ||
- KDRIVE_ID=<id> | ||
- KDRIVE_API_TOKEN=<token> | ||
- KSUITE_API_TOKEN=<token> | ||
ports: | ||
- 4000:4000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
lib/kdrive_bridge/kdrive_client.ex → lib/ksuite_middleware/ksuite_client.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
defmodule KdriveBridge.KdriveClient do | ||
defmodule KsuiteMiddleware.KsuiteClient do | ||
require Logger | ||
use Tesla | ||
|
||
plug Tesla.Middleware.BaseUrl, "https://api.infomaniak.com" | ||
plug Tesla.Middleware.Logger, debug: false | ||
plug Tesla.Middleware.Headers, [{"User-Agent", "kdrive-bridge"}] | ||
plug Tesla.Middleware.Headers, [{"Authorization", "Bearer #{Application.get_env(:kdrive_bridge, :kdrive_api_token)}"}] | ||
plug Tesla.Middleware.Headers, [{"User-Agent", "ksuite-middleware"}] | ||
plug Tesla.Middleware.Headers, [{"Authorization", "Bearer #{Application.get_env(:ksuite_middleware, :ksuite_api_token)}"}] | ||
plug Tesla.Middleware.Headers, [{"Content-Type", "application/json"}] | ||
plug Tesla.Middleware.FollowRedirects, max_redirects: 1 | ||
|
||
@spec download(integer()) :: {:error, any()} | {:ok, Tesla.Env.t()} | ||
def download(file_id) when is_integer(file_id) do | ||
kdrive_id = Application.get_env(:kdrive_bridge, :kdrive_id) | ||
kdrive_id = Application.get_env(:ksuite_middleware, :kdrive_id) | ||
get("/2/drive/#{kdrive_id}/files/#{file_id}/download") | ||
end | ||
|
||
@spec download_as(integer(), bitstring()) :: {:error, any()} | {:ok, Tesla.Env.t()} | ||
def download_as(file_id, as \\ "pdf") when is_integer(file_id) and is_bitstring(as) do | ||
kdrive_id = Application.get_env(:kdrive_bridge, :kdrive_id) | ||
kdrive_id = Application.get_env(:ksuite_middleware, :kdrive_id) | ||
get("/2/drive/#{kdrive_id}/files/#{file_id}/download", query: [as: as]) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...rive_bridge_web/controllers/error_json.ex → ..._middleware_web/controllers/error_json.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.