QuickBase API Cookbook v3 - Recipe #53
Upload all the files in a folder into new QuickBase records
upload folder directory
You want to upload all the files in a folder into a QuickBase table.
require 'QuickBaseClient'

def uploadFiles1(username,password,cwd)
  qbc = QuickBase::Client.new(username,password)
  dbid = qbc.findDBByName(cwd)
  if dbid.nil?
    puts "Creating a QuickBase application called '#{cwd}'."
    dbid = qbc.createDatabase(cwd,"Files uploaded from #{username}\'s #{cwd} folder.")
    qbc.addField(dbid, "Description","text")
    qbc.addField(dbid, "File Attachment","file")
  else
    puts "\nUsing the existing QuickBase application called '#{cwd}'.\n"
    qbc.getSchema(dbid)
    dbid = qbc.lookupChdbid(cwd.dup)
  end
  uploadFiles3(qbc,dbid,"File Attachment",cwd)
  puts "\nYou can repeat this upload using uploadFilesFromFolder.exe #{username} #{password} #{dbid} file_attachment"
end

def uploadFiles2(username,password,dbid,fieldName,cwd)
  qbc = QuickBase::Client.new(username,password)
  uploadFiles3(qbc,dbid,fieldName,cwd)
  puts "\nYou can repeat this upload using uploadFilesFromFolder.exe #{username} #{password} #{dbid} #{fieldName.gsub( /\W/, '_' )}."
end

def uploadFiles3(qbc,dbid,fieldName,cwd)
  Dir.foreach(cwd){|file|
    next if file == "." or file == ".."
    renamedFile = file.dup
    renamedFile.gsub!("&","And")
    renamedFile.gsub!("'"," ")
    if renamedFile != file
       File.rename(file,renamedFile)
    end
    puts "Uploading #{renamedFile}"
    qbc.uploadFile(dbid,renamedFile,fieldName)
  }
  puts "\nFinished uploading files."
end

def getInputAndRun
   mycwd = Dir.pwd.gsub('/','\\')

   if ARGV[3]
     uploadFiles2(ARGV[0],ARGV[1],ARGV[2],ARGV[3],mycwd)
   else
   
     print "\nPlease enter your QuickBase username: "
     username = gets.chomp
     print "\nPlease enter your QuickBase password: "
     password = gets.chomp
     print "\nEnter 'y' if to use or create a '#{mycwd}' QuickBase application for the files: "
     y = gets.chomp
     
     if y == "y" or y == "Y"
       uploadFiles1(username,password,mycwd)
     else
       print "\nPlease enter the id of your target QuickBase table: "
       dbid = gets.chomp
       print "\nPlease enter the name of the QuickBase File Attachment field in your table. (e.g. File): "
       fieldName = gets.chomp
       uploadFiles2(username,password,dbid,fieldName,mycwd)
     end
   end

end

getInputAndRun
This script creates a QuickBase application with the same name as the folder you are in, and uploads all the files from the folder into the application.  Alternatively, you can upload the files into a different table if you know the DBID of the table and the name of the target File Attachment field in the table.

https://www.quickbase.com/db/bcdcajmrg?a=dr&r=b2&rl=s92
https://www.quickbase.com/db/bcdcajmrg?a=dr&r=bz&rl=un4
uploadFilesFromFolder.rb
Ruby wrapper for QuickBase HTTP API One-Click Ruby Installer for Windows
Created on July 25, 2007 at 10:17 PM (PDT). Last updated by Quick Base on Dec. 24, 2007 at  6:15 PM (PST). Owned by Quick Base.
Quick Base
Quick Base
Show fields from Show fields from Show fields from a related table
Report Name *
Description
Reports and Charts Panel
Each table has a panel listing its reports and charts, organized in groups.
Please wait while your new report is saved...
Field label
Column heading override
Justification
What does auto mean?
Fields in:

Fields to Extract:

Name for the new table:
Items in the new table are called:

When you bring additional fields into a conversion, Quickbase often finds inconsistencies. For example, say you're converting your Companies column into its own table. One company, Acme Corporation, has offices in New York, Dallas and Portland. So, when you add the City column to the conversion, Quickbase finds three different locations for Acme. A single value in the column you're converting can only match one value in any additional field. Quickbase needs you to clean up the extra cities before it can create your new table. To do so, you have one of two choices:

  • If you want to create three separate Acme records (Acme-New York, Acme-Dallas and Acme-Portland) click the Conform link at the top of the column.
  • If the dissimilar entries are mistakes (say Acme only has one office in New York and the other locations are data-entry errors) go back into your table and correct the inconsistencies—in this case, changing all locations to New York. Then try the conversion again.

Read more about converting a column into a table.

We're glad you're interested in doing more with Quickbase!

Now we need to make you official before you share apps or manage your account.

Verifying your email lets you share Quickbase with others in your company.

Your work email
Your company