quickbase_client 1.0.21 → 1.0.22

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,5 +1,9 @@
1
1
  == Change History
2
2
 
3
+ 1.0.22 - 11/17/2012 - Added downloadAndSaveFile, uploadFileContents.
4
+
5
+ 1.0.21 - 05/28/2012 - Changed gem homepage to github.
6
+
3
7
  1.0.20 - 11/18/2011 - Added optional dfid param to getRecordAsHTML.
4
8
 
5
9
  1.0.19 - 11/13/2011 - Accommodate Net::HTTP changes in Ruby 1.9.3.
data/README.rdoc CHANGED
@@ -28,6 +28,8 @@ More information about the QuickBase Client is available here -
28
28
 
29
29
  == Change History
30
30
 
31
+ 1.0.22 - 11/17/2012 - Added downloadAndSaveFile, uploadFileContents.
32
+
31
33
  1.0.21 - 05/28/2012 - Changed gem homepage to github.
32
34
 
33
35
  1.0.20 - 11/18/2011 - Added optional dfid param to getRecordAsHTML.
@@ -55,7 +57,7 @@ See CHANGES file for earlier updates.
55
57
 
56
58
  == Questions?
57
59
 
58
- Please submit questions, feedback, suggestions on Intuit's Community Forum at http://community.intuit.com/categories/contents/10298?content_view_type=ALL&sort=2 .
60
+ Please submit questions, feedback, suggestions on Intuit's Community Forum at https://quickbase-community-e2e.intuit.com .
59
61
 
60
62
  == License
61
63
 
@@ -2196,6 +2196,24 @@ class Client
2196
2196
  alias downloadFile downLoadFile
2197
2197
  alias _downloadFile _downLoadFile
2198
2198
 
2199
+ # Download and save a file from a file attachment field in QuickBase.
2200
+ # Use the filename parameter to override the file name from QuickBase.
2201
+ def downloadAndSaveFile( dbid, rid, fid, filename = nil, vid = "0" )
2202
+ response, fileContents = downLoadFile( dbid, rid, fid, vid )
2203
+ if fileContents and fileContents.length > 0
2204
+ if filename and filename.length > 0
2205
+ Misc.save_file( filename, fileContents )
2206
+ else
2207
+ record = getRecord( rid, dbid, [fid] )
2208
+ if record and record[fid] and record[fid].length > 0
2209
+ Misc.save_file( record[fid], fileContents )
2210
+ else
2211
+ Misc.save_file( "#{dbid}_#{rid}_#{fid}", fileContents )
2212
+ end
2213
+ end
2214
+ end
2215
+ end
2216
+
2199
2217
  # API_EditRecord
2200
2218
  def editRecord( dbid, rid, fvlist, disprec = nil, fform = nil, ignoreError = nil, update_id = nil, msInUTC =nil, key = nil )
2201
2219
 
@@ -4535,6 +4553,23 @@ class Client
4535
4553
  nil
4536
4554
  end
4537
4555
 
4556
+ # Add a File Attachment into a new record in a table, using a string containing the file contents.
4557
+ # Additional field values can optionally be set.
4558
+ # e.g. uploadFile( "dhnju5y7", "contacts.txt", "fred: 1-222-333-4444", "Contacts File", { "Notes" => "#{Time.now}" }
4559
+ def uploadFileContents( dbid, filename, fileContents, fileAttachmentFieldName, additionalFieldsToSet = nil )
4560
+ if dbid and filename and fileAttachmentFieldName
4561
+ clearFieldValuePairList
4562
+ addFieldValuePair( fileAttachmentFieldName, nil, filename, fileContents )
4563
+ if additionalFieldsToSet and additionalFieldsToSet.is_a?( Hash )
4564
+ additionalFieldsToSet.each{ |fieldName,fieldValue|
4565
+ addFieldValuePair( fieldName, nil, nil, fieldValue )
4566
+ }
4567
+ end
4568
+ return addRecord( dbid, @fvlist )
4569
+ end
4570
+ nil
4571
+ end
4572
+
4538
4573
  # Upload a file into a new record in the active table.
4539
4574
  # e.g. uploadFile( "contacts.txt", "Contacts File" )
4540
4575
  def _uploadFile( filename, fileAttachmentFieldName )
data/lib/QuickBaseMisc.rb CHANGED
@@ -94,11 +94,24 @@ module QuickBase
94
94
 
95
95
  def Misc.listUserToArray(listUser)
96
96
  listUser.split(/;/)
97
- end
97
+ end
98
98
 
99
99
  def Misc.arrayToListUser(array)
100
100
  array.join(";")
101
- end
101
+ end
102
+
103
+ def Misc.save_file(filename, contents, mode="wb")
104
+ File.open(filename, mode){|f|
105
+ f.write(contents)
106
+ f.flush
107
+ }
108
+ rescue StandardError => error
109
+ new_filename = filename.gsub(/\W/,"_")
110
+ File.open(new_filename, mode){|f|
111
+ f.write(contents)
112
+ f.flush
113
+ }
114
+ end
102
115
 
103
116
  end
104
117
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quickbase_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.21
4
+ version: 1.0.22
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-28 00:00:00.000000000 Z
12
+ date: 2012-11-17 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Wraps the QuickBase HTTP API and adds classes and methods to minimize
15
15
  the amount of code needed to get useful things done.