Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
liexin_supplier
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
cd0534ed
authored
Sep 03, 2024
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
修改上传地址
parent
69c4b659
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
7 deletions
app/Http/Services/DealImageService.php
app/Http/routes.php
app/Http/Services/DealImageService.php
View file @
cd0534ed
...
...
@@ -18,12 +18,16 @@ class DealImageService
preg_match_all
(
$pattern
,
$text
,
$matches
);
$imageUrls
=
$matches
[
1
];
$pattern
=
'/<img [^>]*src\s*=\s*["\']?([^"\'>]*file\.liexindev\.net[^"\'>]*)/i'
;
preg_match_all
(
$pattern
,
$text
,
$matches
);
$imageUrls
=
array_merge
(
$imageUrls
,
$matches
[
1
]);
return
$imageUrls
;
}
public
static
function
checkImage
(
$link
)
{
if
(
strpos
(
$link
,
'img.ichunt.com'
)
!==
false
||
strpos
(
$link
,
'file.ichunt.
com'
)
!==
false
||
strpos
(
$link
,
'file.liexindev.com
'
)
!==
false
)
{
if
(
strpos
(
$link
,
'img.ichunt.com'
)
!==
false
||
strpos
(
$link
,
'file.ichunt.
net'
)
!==
false
||
strpos
(
$link
,
'file.liexindev.net
'
)
!==
false
)
{
return
$link
;
}
else
{
return
''
;
...
...
@@ -201,14 +205,14 @@ class DealImageService
}
try
{
$info
=
pathinfo
(
$url
);
$path
=
storage_path
(
'logs/'
)
.
md5
(
$url
)
.
'.'
.
$info
[
'extension'
];
;
$path
=
storage_path
(
'logs/'
)
.
md5
(
$url
);
$client
=
new
\GuzzleHttp\Client
();
$response
=
$client
->
get
(
$url
);
$contents
=
$response
->
getBody
()
->
getContents
();
file_put_contents
(
$path
,
$contents
);
//然后上传到图片服务器
$response
=
$client
->
request
(
'POST'
,
env
(
'IMAGE_SERVER_URL'
)
.
'/upload
Fil
e?sys_type=5&create_uid=1000'
,
[
$response
=
$client
->
request
(
'POST'
,
env
(
'IMAGE_SERVER_URL'
)
.
'/upload
Imag
e?sys_type=5&create_uid=1000'
,
[
'multipart'
=>
[
[
'name'
=>
'file'
,
...
...
@@ -216,17 +220,15 @@ class DealImageService
]
]
]);
if
(
$response
->
getStatusCode
()
!=
200
)
{
dump
(
'上传网络错误'
);
continue
;
}
$res
=
json_decode
(
$response
->
getBody
()
->
getContents
(),
true
);
if
(
isset
(
$res
[
'code'
]))
{
if
(
$res
[
'code'
]
==
0
)
{
$ossFileUrl
=
$res
[
'data'
][
'oss_
fil
e_url'
];
$ossFileUrl
=
$res
[
'data'
][
'oss_
imag
e_url'
];
$imageMap
[
$url
]
=
$ossFileUrl
;
}
else
{
dump
(
'上传服务接口返回错误 : '
.
json_encode
(
$res
));
...
...
app/Http/routes.php
View file @
cd0534ed
...
...
@@ -84,7 +84,7 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function ()
});
Route
::
match
([
'get'
,
'post'
],
'/test'
,
function
()
{
\App\Http\Services\DealImageService
::
deal
Cm
sImage
();
\App\Http\Services\DealImageService
::
deal
New
sImage
();
//\App\Http\Services\SupplierAddressService::initUnitedAddress();
//\App\Http\Services\DataService::checkSupplierBandAccount();
//(new CompanyService())->checkSupplierCompanyAndAddress(11042);
...
...
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