postgresql_lo_streamer 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/controllers/postgresql_lo_streamer/lo_controller.rb +22 -1
- data/lib/postgresql_lo_streamer/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bbfc0cb9ae078d03087880f6b0ad6c6f32ca4f66
|
4
|
+
data.tar.gz: 55c72abfb7103f6df8a18bea5dd164fdf7be2e86
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 876522e92fe8318eeae03d0630093e0052d5ed537127710fcd1909e39588e6014503f3aa46982ec6630bbfaaa806875593d9844fa82ba77c6aa605924617df69
|
7
|
+
data.tar.gz: 371246ea78633323dda68052baaa9e68748733c54645b6c0ac6419c77ee95b367c644edc014e84014bdaf981f0c8bfbcc2ab748a36bf6f73abe83375187e5e9e
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
This gem adds to your application a controller that can read PostgreSQL Large Objects and stream them to a HTTP client.
|
4
4
|
|
5
|
-
For more information on PostgreSQL Large Objects you can take a look at the [official docs](http://www.postgresql.org/docs/
|
5
|
+
For more information on PostgreSQL Large Objects you can take a look at the [official docs](http://www.postgresql.org/docs/current/static/largeobjects.html)
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
@@ -4,10 +4,17 @@ module PostgresqlLoStreamer
|
|
4
4
|
class LoController < ActionController::Base
|
5
5
|
def stream
|
6
6
|
send_file_headers! configuration.options
|
7
|
+
|
8
|
+
object_identifier = params[:id].to_i
|
9
|
+
if !object_exists?(object_identifier)
|
10
|
+
self.status = 404
|
11
|
+
render :nothing => true and return
|
12
|
+
end
|
13
|
+
|
7
14
|
self.status = 200
|
8
15
|
self.response_body = Enumerator.new do |y|
|
9
16
|
connection.transaction do
|
10
|
-
lo = connection.lo_open(
|
17
|
+
lo = connection.lo_open(object_identifier, ::PG::INV_READ)
|
11
18
|
while data = connection.lo_read(lo, 4096) do
|
12
19
|
y << data
|
13
20
|
end
|
@@ -21,7 +28,21 @@ module PostgresqlLoStreamer
|
|
21
28
|
end
|
22
29
|
|
23
30
|
private
|
31
|
+
|
32
|
+
def object_exists?(identifier)
|
33
|
+
begin
|
34
|
+
connection.lo_open(identifier, ::PG::INV_READ)
|
35
|
+
rescue PG::Error => e
|
36
|
+
if e.to_s.include? "does not exist"
|
37
|
+
return false
|
38
|
+
end
|
39
|
+
|
40
|
+
raise
|
41
|
+
end
|
24
42
|
|
43
|
+
return true
|
44
|
+
end
|
45
|
+
|
25
46
|
def configuration
|
26
47
|
PostgresqlLoStreamer.configuration
|
27
48
|
end
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: postgresql_lo_streamer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Diogo Biazus
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '4.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '4.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|