Skip to content

Commit

Permalink
feat(uploads): add temp link env vars
Browse files Browse the repository at this point in the history
for customising the maximum and default timeouts
  • Loading branch information
stakach committed Feb 29, 2024
1 parent 165e54d commit e469887
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions shard.lock
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ shards:

placeos-core:
git: https://github.com/placeos/core.git
version: 4.11.10+git.commit.2f03b1ede7c15da99201c7caadb9f50f885c71b2
version: 4.11.10+git.commit.2e0f5200df837913a5d9c75b5b7c13d7c2a84eb8

placeos-core-client: # Overridden
git: https://github.com/placeos/core-client.git
Expand All @@ -267,7 +267,7 @@ shards:

placeos-models:
git: https://github.com/placeos/models.git
version: 9.37.4
version: 9.38.2

placeos-resource:
git: https://github.com/place-labs/resource.git
Expand Down
4 changes: 4 additions & 0 deletions src/constants.cr
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ module PlaceOS::Api
OPENAI_API_MODEL = ENV["OPENAI_API_MODEL"]? || "gpt-4-1106-preview"
OPENAI_MAX_TOKENS = ENV["OPENAI_MAX_TOKENS"]?.try(&.to_i) || 11264

# Upload temporary links
TEMP_LINK_MAX_MINUTES = ENV["TEMP_LINK_MAX_MINUTES"]?.try(&.to_i) || 1440
TEMP_LINK_DEFAULT_MINUTES = ENV["TEMP_LINK_DEFAULT_MINUTES"]?.try(&.to_i) || TEMP_LINK_MAX_MINUTES

# CHANGELOG
#################################################################################################

Expand Down
5 changes: 3 additions & 2 deletions src/placeos-rest-api/controllers/uploads.cr
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,10 @@ module PlaceOS::Api
@[AC::Route::GET("/:id/url")]
def get_link(
@[AC::Param::Info(description: "Link expiry period in minutes.", example: "60")]
expiry : Int32 = 1440
expiry : Int32 = TEMP_LINK_DEFAULT_MINUTES
)
expiry = expiry > 1440 ? 1440 : expiry
max_expiry = TEMP_LINK_MAX_MINUTES
expiry = expiry > max_expiry ? max_expiry : expiry
unless storage = current_upload.storage
Log.warn { {message: "upload object associated storage not found", upload_id: current_upload.id, authority: authority.id, user: current_user.id} }
raise Error::NotFound.new("Upload missing associated storage")
Expand Down

0 comments on commit e469887

Please sign in to comment.