1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace POData\Providers\Stream; |
4
|
|
|
|
5
|
|
|
use POData\Providers\Metadata\ResourceStreamInfo; |
6
|
|
|
use POData\OperationContext\IOperationContext; |
7
|
|
|
use POData\Common\ODataException; |
8
|
|
|
|
9
|
|
|
class SimpleStreamProvider implements IStreamProvider2 |
10
|
|
|
{ |
11
|
|
|
public function getReadStream( |
12
|
|
|
$entity, |
13
|
|
|
$eTag, |
14
|
|
|
$checkETagForEquality, |
15
|
|
|
IOperationContext $operationContext |
16
|
|
|
) { |
17
|
|
|
return null; // TODO: find default stream and return. |
18
|
|
|
} |
19
|
|
|
public function getStreamContentType($entity,IOperationContext $operationContext) |
20
|
|
|
{ |
21
|
|
|
return 'application/octet-stream'; |
22
|
|
|
} |
23
|
|
|
public function getStreamETag($entity, IOperationContext $operationContext) |
24
|
|
|
{ |
25
|
|
|
return null; // TODO: find default stream and return. |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
public function getReadStreamUri($entity, IOperationContext $operationContext) |
29
|
|
|
{ |
30
|
|
|
//let library creates default media url. |
31
|
|
|
return null; |
32
|
|
|
} |
33
|
|
|
public function getReadStream2($entity, ResourceStreamInfo $resourceStreamInfo, $eTag, $checkETagForEquality, IOperationContext $operationContext) |
34
|
|
|
{ |
35
|
|
|
|
36
|
|
|
$name = $resourceStreamInfo->getName(); |
37
|
|
|
return $entity->$name; |
38
|
|
|
} |
39
|
|
|
public function getStreamContentType2($entity, ResourceStreamInfo $resourceStreamInfo, IOperationContext $operationContext) |
40
|
|
|
{ |
41
|
|
|
return 'application/octet-stream'; |
42
|
|
|
} |
43
|
|
|
public function getStreamETag2( |
44
|
|
|
$entity, |
45
|
|
|
ResourceStreamInfo $resourceStreamInfo, |
46
|
|
|
IOperationContext $operationContext |
47
|
|
|
) { |
48
|
|
|
$name = $resourceStreamInfo->getName(); |
49
|
|
|
return sha1($entity->$name); |
50
|
|
|
} |
51
|
|
|
public function getReadStreamUri2( |
52
|
|
|
$entity, |
53
|
|
|
ResourceStreamInfo $resourceStreamInfo, |
54
|
|
|
IOperationContext $operationContext |
55
|
|
|
) { |
56
|
|
|
//let library creates default media url. |
57
|
|
|
return null; |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|