Skip to content

Fb/s3 temp copy support - #1

Open
seenivasanpalanisamy wants to merge 5 commits into
FB/RED-5787/optional_attachmentfrom
FB/s3_temp_copy_support
Open

Fb/s3 temp copy support#1
seenivasanpalanisamy wants to merge 5 commits into
FB/RED-5787/optional_attachmentfrom
FB/s3_temp_copy_support

Conversation

@seenivasanpalanisamy

Copy link
Copy Markdown
Collaborator

No description provided.

# dock never accepts more than the final record would validate anyway.
def authenticated_s3_post(temp_key, options = {})
max_size = options[:max_size] || attachment_options[:temp_max_size] || attachment_options[:max_size]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to check content type?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do our gem need to handle those?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

our sfym code must validate that

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

content-type handling done on model level

# logged and left for the bucket's lifecycle rule to clean up instead.
def save_from_temp_key!(temp_key, options = {})
was_new_record = new_record? # only destroy a row we just created, never a pre-existing one
old_full_filename = File.join(attachment_options[:temp_path_prefix], temp_key)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we have restriction in simplifyem server, to always have temp key starting with user_xx_entity_xxx

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

@old_filename = nil
save!

copy_file(old_full_filename, full_filename, temp_bucket)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if copy fails?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it will destroy the record and throw error

# temp_path_prefix/temp_expires_in defaults live in S3Backend.included instead (the only
# backend that reads them) -- setting them here, before that runs, would permanently
# shadow any amazon_s3.yml-level default with this literal.
options[:content_type] = [options[:content_type]].flatten.collect! { |t| t == :image ? ::Technoweenie::AttachmentFu.content_types : t }.flatten unless options[:content_type].nil?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can u check on thumbnail too? how master works and how forked version works?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed thumbnail generation issue

# filename, the file it replaces) is best-effort: a failure there doesn't roll back an
# already-successful adoption (record saved, file at its permanent key) -- it's
# logged and left for the bucket's lifecycle rule to clean up instead.
def save_from_temp_key!(temp_key, options = {})

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check what happens when the file is deleted because it was classified as malicious. It should handle it gracefully and log it properly when the temp key not found

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@amit-trex amit-trex left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants