在将图像上传到s3之前是否必须先下载图像?

时间:2019-05-07 17:56:27

标签: ruby-on-rails aws-sdk aws-sdk-ruby

我有带有嵌入式图像的Rails应用程序。我想要的是将图像上传到s3并从那里提供主题,而不是从原始来源中获取主题。在将img上传到s3之前,我是否必须将img下载到服务器上?

1 个答案:

答案 0 :(得分:1)

简短的回答:如果您要抓取某人的内容,那么...是的,您需要先将文件下拉,然后再上传到S3。

长回答:如果其他站点(原始源)正在与您合作,则可以给他们提供一个预签名URL,他们可以使用该URL上载到S3存储桶。

摘自Amazon文档:https://docs.aws.amazon.com/AmazonS3/latest/dev/UploadObjectPreSignedURLRubySDK.html

    Shared Function SendEmail(ByVal sFrom As String, ByVal sEmailAddress As String, ByVal sSubject As String, ByVal sBody As String, Optional ByVal sBcc As String = "") As Boolean

        Dim result As Boolean
        Dim mMessage As MailMessage = New MailMessage(sFrom, sEmailAddress, sSubject, sBody)                '(sFrom, sEmailAddress, sSubject, sBody)
        If Not String.IsNullOrEmpty(sBcc) Then
            mMessage.Bcc.Add(sBcc)
        End If
        mMessage.IsBodyHtml = True
        Dim smtpCli As SmtpClient = New SmtpClient
        Try
            smtpCli.Send(mMessage)
            result = True
        Catch ex As Exception
            Dim logger As log4net.ILog = log4net.LogManager.GetLogger("EmailLog")
            logger.Error("Member.vb Member.SendEmail - " & ex.StackTrace & ex.Message)
            result = False
        End Try

        Return result

    End Function