gemini_upload-rails 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  module GeminiUpload
2
2
  module Rails
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
@@ -51,13 +51,39 @@ $.fn.extend({
51
51
  }
52
52
  return $form.get(0).setAttribute('action', "https://" + uploadBucket + ".s3.amazonaws.com");
53
53
  },
54
+ makeGeminiApiCall: function(data, originalKey, bucket, options, metadata) {
55
+ var key, fileName;
56
+ fileName = data.files[0].name;
57
+ key = originalKey.replace('${filename}', fileName);
58
+ return $.ajax({
59
+ type: 'POST',
60
+ dataType: 'json',
61
+ url: "" + options.geminiApp + "/entries.json",
62
+ data: {
63
+ entry: {
64
+ source_key: key,
65
+ source_bucket: bucket,
66
+ template_key: options.templateKey,
67
+ metadata: metadata,
68
+ extract_geometry: options.extractGeometry
69
+ }
70
+ },
71
+ headers: {
72
+ 'Authorization': "Basic " + options.credentials
73
+ },
74
+ success: function(resp) {
75
+ if (typeof options.successCb != 'undefined' && options.successCb != null) {
76
+ options.successCb(resp, metadata);
77
+ }
78
+ }
79
+ });
80
+ },
54
81
  attachFileUploadUI: function(data, options) {
55
82
  var $form, bucket, key, metadata, originalKey;
56
83
  $form = this.find('form');
57
84
  bucket = data.policy_document.conditions[0].bucket;
58
85
  originalKey = "" + data.policy_document.conditions[1][2] + "/${filename}";
59
86
  this.seedForm(data, options);
60
- metadata = options.metadata;
61
87
  return $form.fileupload({
62
88
  type: 'POST',
63
89
  dataType: 'xml',
@@ -65,32 +91,14 @@ $.fn.extend({
65
91
  return function(e, data) {
66
92
  var fileName;
67
93
  if (typeof options.onDone != 'undefined' && options.onDone != null) {
68
- options.onDone(e, data);
69
- }
70
- fileName = data.files[0].name;
71
- key = originalKey.replace('${filename}', fileName);
72
- return $.ajax({
73
- type: 'POST',
74
- dataType: 'json',
75
- url: "" + options.geminiApp + "/entries.json",
76
- data: {
77
- entry: {
78
- source_key: key,
79
- source_bucket: bucket,
80
- template_key: options.templateKey,
81
- metadata: metadata,
82
- extract_geometry: options.extractGeometry
83
- }
84
- },
85
- headers: {
86
- 'Authorization': "Basic " + options.credentials
87
- },
88
- success: function(resp) {
89
- if (typeof options.successCb != 'undefined' && options.successCb != null) {
90
- options.successCb(resp);
91
- }
94
+ if (typeof options.useDataFromDone != 'undefined' && options.useDataFromDone) {
95
+ options.onDone(e, data, originalKey, bucket, options, _this.makeGeminiApiCall)
96
+ }
97
+ else {
98
+ options.onDone(e, data);
99
+ _this.makeGeminiApiCall(data, originalKey, bucket, options, options.metadata);
92
100
  }
93
- });
101
+ }
94
102
  };
95
103
  })(this),
96
104
  add: (function(_this) {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gemini_upload-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
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: 2014-10-24 00:00:00.000000000 Z
12
+ date: 2014-10-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler