如何使用paperclip或carriervawe将生成的xls(不上传表单)文件保存到ActiveRecord并使用它然后上传到amazon s3?
Sub DoFolderPart1()
Dim FileSystem As Object
Dim HostFolder As String
HostFolder = "K:\Data Directories\Acquisitions"
Set FileSystem = CreateObject("Scripting.FileSystemObject")
DoFolder FileSystem.GetFolder(HostFolder)
End Sub
Sub DoFolder(Folder)
' Declaring your variables
Dim SubFolder
Dim strName As String
Dim pos As Integer
' Looping through your folders recursively
' We go into each folder until we find a folder with only files
For Each SubFolder In Folder.SubFolders
DoFolder SubFolder
Next
' If we find only files or we have already opened all of the subfolders
Dim File
strName = Folder.name '<-- Store the folder name
' Find the string "June 2015" in the folder name and store the
' starting location as "pos"
pos = InStr(strName, "June 2015")
If pos > 0 Then '<-- If we found "June 2015"...
For Each File In Folder.Files' <-- Go through each file
If Right(File, 4) = "xlsx" Then '<-- if it's excel
Workbooks.Open Filename:=File ' open it
'I want to put code here
End If
Next
End If
End Sub
这是我生成的xls文件,但我需要将其永久保存,以便在s3上使用延迟作业上传它。
答案 0 :(得分:0)
使用Carrierwave,您可以将正常文件分配给上传器的安装点,然后保存模型。
然后Carrierwave将处理所有上传。
所以,如果你有一个模特
class Project < ActiveRecord::Base
mount_uploader :xml_file, XmlUploader
end
你可以写
pro=Project.new
pro.xml_file = file # your generated tempfile
pro.save
我不熟悉回形针。