我不必使用ActiveStorage存储base64文件,我从客户端接收到base64字符串
params["image"] = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAREAAABMCAYAAABK84MTAAAABHNCSVQICAgIfAhkl0RVh"
当我尝试附加它时,我得到:
ActiveSupport::MessageVerifier::InvalidSignature(ActiveSupport::MessageVerifier::InvalidSignature):
我遵循了许多教程,尝试先对其进行解码:
decoded_image = Base64.decode64(params["image"])
post.image.attach(decoded_image)
以及使用以下命令从字符串中删除data:image / png; base64部分
decoded_image = Base64.decode64(params["image"]['data:image/png;base64,'.length .. -1])
当我直接使用以下文件从文件中添加图像时,没有成功附加图像:
file = open("image.png")
post.image.attach(io: file, filename: "post.png")
它工作得很好,所以我认为我的错误是在字符串解析期间
答案 0 :(得分:0)
我不确定是否可以使用,但是尝试使用这种方法使用Sub DeleteRows()
' DeleteRows Macro
'you should always set the workbook and worksheet
Dim ws As Worksheet: Set ws = ThisWorkbook.Sheets("Sheet1")
'assign a last row variable using .End(xlUp).Row
Dim lRow As Long: lRow = ws.Range("B" & ws.Rows.Count).End(xlUp).Row
'loop from the last row to the second row(skip header)
For i = lRow To 2 Step -1
'use Cells to set the row and column and check for "M of E".
If ws.Cells(i, "B").Value <> "M of E" Then
'If the cell in Column B doesn't contain "M of E", delete the row.
ws.Cells(i, "B").EntireRow.Delete
End If
Next i 'loop
End Sub
创建一个临时文件:
Tempfile