File tree Expand file tree Collapse file tree 1 file changed +22
-3
lines changed Expand file tree Collapse file tree 1 file changed +22
-3
lines changed Original file line number Diff line number Diff line change 9595 $ status = false ;
9696 $ handle = fopen (TESTFILE , "rb " );
9797 while (!$ status && !feof ($ handle )) {
98- $ chunk = fread ($ handle , $ chunkSizeBytes );
98+ // read until you get $chunkSizeBytes from TESTFILE
99+ // fread will never return more than 8192 bytes if the stream is read buffered and it does not represent a plain file
100+ // An example of a read buffered file is when reading from a URL
101+ $ chunk = readVideoChunk ($ handle , $ chunkSizeBytes );
99102 $ status = $ media ->nextChunk ($ chunk );
100103 }
101104
113116 echo missingClientSecretsWarning ();
114117 exit ;
115118}
119+ function readVideoChunk ($ handle , $ chunkSize )
120+ {
121+ $ byteCount = 0 ;
122+ $ giantChunk = "" ;
123+ while (!feof ($ handle )) {
124+ // fread will never return more than 8192 bytes if the stream is read buffered and it does not represent a plain file
125+ $ chunk = fread ($ handle , 8192 );
126+ $ byteCount += strlen ($ chunk );
127+ $ giantChunk .= $ chunk ;
128+ if ($ byteCount >= $ chunkSize )
129+ {
130+ return $ giantChunk ;
131+ }
132+ }
133+ return $ giantChunk ;
134+ }
116135?>
117136<div class="box">
118137 <div class="request">
119- <?php
138+ <?php
120139if (isset ($ authUrl )) {
121140 echo "<a class='login' href=' " . $ authUrl . "'>Connect Me!</a> " ;
122141}
123142?>
124143 </div>
125144
126145 <div class="shortened">
127- <?php
146+ <?php
128147if (isset ($ result ) && $ result ) {
129148 var_dump ($ result );
130149}
You can’t perform that action at this time.
0 commit comments