Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
ipfs-mediashare
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
alexm98
ipfs-mediashare
Commits
43054fce
Commit
43054fce
authored
May 20, 2018
by
alexm98
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added setMimeHeader, works for PDF,PNG and GIFs. Need to check other mimes.
parent
13e080c6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
5 deletions
+16
-5
FileController.php
app/Http/Controllers/FileController.php
+16
-5
No files found.
app/Http/Controllers/FileController.php
View file @
43054fce
...
...
@@ -31,13 +31,22 @@ class FileController extends Controller
foreach
(
$mimes
as
$key
=>
$value
){
if
(
strpos
(
$hex
,
$value
)
!==
FALSE
){
echo
$key
;
return
$key
;
}
}
}
public
function
setMimeHeader
(){
// set correct header for showing the data type
public
function
setMimeHeader
(
$mimetype
){
$headers
=
[
'PDF'
=>
'application/pdf'
,
'PNG'
=>
'image/png'
,
'GIF'
=>
'image/gif'
,
];
// error supressing @headers[$mimetype] because it might fatal err to undefined index
if
(
@
$headers
[
$mimetype
]
!=
NULL
){
header
(
'Content-Type:'
.
$headers
[
$mimetype
]);
}
}
/**
...
...
@@ -79,8 +88,10 @@ class FileController extends Controller
*/
public
function
show
(
$hash
)
{
// echo $this->ipfs->cat($hash);
self
::
getMime
(
$hash
);
$mime
=
self
::
getMime
(
$hash
);
self
::
setMimeHeader
(
$mime
);
echo
$this
->
ipfs
->
cat
(
$hash
);
}
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment