Completed
Push — master ( 647b18...1a99e0 )
by Robin
22:10 queued 05:29
created
lib/private/Files/ObjectStore/S3ObjectTrait.php 2 patches
Doc Comments   +8 added lines patch added patch discarded remove patch
@@ -74,6 +74,10 @@  discard block
 block discarded – undo
74 74
 
75 75
 	}
76 76
 
77
+	/**
78
+	 * @param string $urn
79
+	 * @param resource $stream
80
+	 */
77 81
 	protected function singlePartUpload($urn, $stream) {
78 82
 		$this->getConnection()->putObject([
79 83
 			'Bucket' => $this->bucket,
@@ -82,6 +86,10 @@  discard block
 block discarded – undo
82 86
 		]);
83 87
 	}
84 88
 
89
+	/**
90
+	 * @param string $urn
91
+	 * @param resource $stream
92
+	 */
85 93
 	protected function multiPartUpload($urn, $stream) {
86 94
 		$uploader = new MultipartUploader($this->getConnection(), $stream, [
87 95
 			'bucket' => $this->bucket,
Please login to merge, or discard this patch.
Indentation   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -29,97 +29,97 @@
 block discarded – undo
29 29
 const S3_UPLOAD_PART_SIZE = 524288000; // 500MB
30 30
 
31 31
 trait S3ObjectTrait {
32
-	/**
33
-	 * Returns the connection
34
-	 *
35
-	 * @return S3Client connected client
36
-	 * @throws \Exception if connection could not be made
37
-	 */
38
-	abstract protected function getConnection();
32
+    /**
33
+     * Returns the connection
34
+     *
35
+     * @return S3Client connected client
36
+     * @throws \Exception if connection could not be made
37
+     */
38
+    abstract protected function getConnection();
39 39
 
40
-	/**
41
-	 * @param string $urn the unified resource name used to identify the object
42
-	 * @return resource stream with the read data
43
-	 * @throws \Exception when something goes wrong, message will be logged
44
-	 * @since 7.0.0
45
-	 */
46
-	function readObject($urn) {
47
-		$client = $this->getConnection();
48
-		$command = $client->getCommand('GetObject', [
49
-			'Bucket' => $this->bucket,
50
-			'Key' => $urn
51
-		]);
52
-		$command['@http']['stream'] = true;
53
-		$result = $client->execute($command);
54
-		/** @var StreamInterface $body */
55
-		$body = $result['Body'];
40
+    /**
41
+     * @param string $urn the unified resource name used to identify the object
42
+     * @return resource stream with the read data
43
+     * @throws \Exception when something goes wrong, message will be logged
44
+     * @since 7.0.0
45
+     */
46
+    function readObject($urn) {
47
+        $client = $this->getConnection();
48
+        $command = $client->getCommand('GetObject', [
49
+            'Bucket' => $this->bucket,
50
+            'Key' => $urn
51
+        ]);
52
+        $command['@http']['stream'] = true;
53
+        $result = $client->execute($command);
54
+        /** @var StreamInterface $body */
55
+        $body = $result['Body'];
56 56
 
57
-		return $body->detach();
58
-	}
57
+        return $body->detach();
58
+    }
59 59
 
60
-	/**
61
-	 * @param string $urn the unified resource name used to identify the object
62
-	 * @param resource $stream stream with the data to write
63
-	 * @throws \Exception when something goes wrong, message will be logged
64
-	 * @since 7.0.0
65
-	 */
66
-	function writeObject($urn, $stream) {
67
-		$stat = fstat($stream);
60
+    /**
61
+     * @param string $urn the unified resource name used to identify the object
62
+     * @param resource $stream stream with the data to write
63
+     * @throws \Exception when something goes wrong, message will be logged
64
+     * @since 7.0.0
65
+     */
66
+    function writeObject($urn, $stream) {
67
+        $stat = fstat($stream);
68 68
 
69
-		if ($stat['size'] && $stat['size'] < S3_UPLOAD_PART_SIZE) {
70
-			$this->singlePartUpload($urn, $stream);
71
-		} else {
72
-			$this->multiPartUpload($urn, $stream);
73
-		}
69
+        if ($stat['size'] && $stat['size'] < S3_UPLOAD_PART_SIZE) {
70
+            $this->singlePartUpload($urn, $stream);
71
+        } else {
72
+            $this->multiPartUpload($urn, $stream);
73
+        }
74 74
 
75
-	}
75
+    }
76 76
 
77
-	protected function singlePartUpload($urn, $stream) {
78
-		$this->getConnection()->putObject([
79
-			'Bucket' => $this->bucket,
80
-			'Key' => $urn,
81
-			'Body' => $stream
82
-		]);
83
-	}
77
+    protected function singlePartUpload($urn, $stream) {
78
+        $this->getConnection()->putObject([
79
+            'Bucket' => $this->bucket,
80
+            'Key' => $urn,
81
+            'Body' => $stream
82
+        ]);
83
+    }
84 84
 
85
-	protected function multiPartUpload($urn, $stream) {
86
-		$uploader = new MultipartUploader($this->getConnection(), $stream, [
87
-			'bucket' => $this->bucket,
88
-			'key' => $urn,
89
-			'part_size' => S3_UPLOAD_PART_SIZE
90
-		]);
85
+    protected function multiPartUpload($urn, $stream) {
86
+        $uploader = new MultipartUploader($this->getConnection(), $stream, [
87
+            'bucket' => $this->bucket,
88
+            'key' => $urn,
89
+            'part_size' => S3_UPLOAD_PART_SIZE
90
+        ]);
91 91
 
92
-		$tries = 0;
92
+        $tries = 0;
93 93
 
94
-		do {
95
-			try {
96
-				$result = $uploader->upload();
97
-			} catch (MultipartUploadException $e) {
98
-				\OC::$server->getLogger()->logException($e);
99
-				rewind($stream);
100
-				$tries++;
94
+        do {
95
+            try {
96
+                $result = $uploader->upload();
97
+            } catch (MultipartUploadException $e) {
98
+                \OC::$server->getLogger()->logException($e);
99
+                rewind($stream);
100
+                $tries++;
101 101
 
102
-				if ($tries < 5) {
103
-					$uploader = new MultipartUploader($this->getConnection(), $stream, [
104
-						'state' => $e->getState()
105
-					]);
106
-				} else {
107
-					$this->getConnection()->abortMultipartUpload($e->getState()->getId());
108
-				}
109
-			}
110
-		} while (!isset($result) && $tries < 5);
111
-	}
102
+                if ($tries < 5) {
103
+                    $uploader = new MultipartUploader($this->getConnection(), $stream, [
104
+                        'state' => $e->getState()
105
+                    ]);
106
+                } else {
107
+                    $this->getConnection()->abortMultipartUpload($e->getState()->getId());
108
+                }
109
+            }
110
+        } while (!isset($result) && $tries < 5);
111
+    }
112 112
 
113
-	/**
114
-	 * @param string $urn the unified resource name used to identify the object
115
-	 * @return void
116
-	 * @throws \Exception when something goes wrong, message will be logged
117
-	 * @since 7.0.0
118
-	 */
119
-	function deleteObject($urn) {
120
-		$this->getConnection()->deleteObject([
121
-			'Bucket' => $this->bucket,
122
-			'Key' => $urn
123
-		]);
124
-	}
113
+    /**
114
+     * @param string $urn the unified resource name used to identify the object
115
+     * @return void
116
+     * @throws \Exception when something goes wrong, message will be logged
117
+     * @since 7.0.0
118
+     */
119
+    function deleteObject($urn) {
120
+        $this->getConnection()->deleteObject([
121
+            'Bucket' => $this->bucket,
122
+            'Key' => $urn
123
+        ]);
124
+    }
125 125
 }
Please login to merge, or discard this patch.