Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
ppt_server
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Li Feifei
ppt_server
Commits
8570754f
Commit
8570754f
authored
May 13, 2021
by
Li Feifei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test
parent
c8ce46fa
Pipeline
#14620
failed with stages
in 39 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
32 deletions
+55
-32
upload.go
upload/upload.go
+55
-32
No files found.
upload/upload.go
View file @
8570754f
...
@@ -11,6 +11,7 @@ import (
...
@@ -11,6 +11,7 @@ import (
"github.com/aliyun/aliyun-oss-go-sdk/oss"
"github.com/aliyun/aliyun-oss-go-sdk/oss"
"github.com/astaxie/beego/orm"
"github.com/astaxie/beego/orm"
"github.com/chai2010/webp"
"github.com/chai2010/webp"
"github.com/xxjwxc/gowp/workpool"
"image"
"image"
"image/jpeg"
"image/jpeg"
"image/png"
"image/png"
...
@@ -27,6 +28,7 @@ import (
...
@@ -27,6 +28,7 @@ import (
"runtime/debug"
"runtime/debug"
"strconv"
"strconv"
"strings"
"strings"
"sync"
"time"
"time"
)
)
...
@@ -36,13 +38,19 @@ var (
...
@@ -36,13 +38,19 @@ var (
WEBURL
string
=
"https://test-live.offcncloud.com"
WEBURL
string
=
"https://test-live.offcncloud.com"
client
*
http
.
Client
client
*
http
.
Client
token
string
token
string
once
sync
.
Once
Pool
*
workpool
.
WorkPool
)
)
const
docUrl
string
=
"http://doc.offcncloud.com/"
const
docUrl
string
=
"http://doc.offcncloud.com/"
func
init
()
{
once
.
Do
(
func
()
{
Pool
=
workpool
.
New
(
10
)
})
}
//func main() {
//func main() {
...
@@ -253,44 +261,58 @@ func Down(v *models.XyuSmallTempFiles) {
...
@@ -253,44 +261,58 @@ func Down(v *models.XyuSmallTempFiles) {
ch1
:=
make
(
chan
bool
)
ch1
:=
make
(
chan
bool
)
for
_
,
file
:=
range
reader
.
File
{
for
_
,
file
:=
range
reader
.
File
{
Pool
.
DoWait
(
func
()
error
{
go
func
(
file
*
zip
.
File
)
{
var
err
error
defer
debug
.
FreeOSMemory
()
err
:=
pdfThumbnail
(
objectPath
,
file
,
bucket
)
if
err
!=
nil
{
fmt
.
Println
(
objectPath
+
file
.
Name
+
"上传失败"
)
// 上传缩略图失败,重试3次
for
i
:=
0
;
i
<
3
;
i
++
{
for
i
:=
0
;
i
<
3
;
i
++
{
err
=
pdfThumbnail
(
objectPath
,
file
,
bucket
)
if
err
=
pdfThumbnail
(
objectPath
,
file
,
bucket
);
err
==
nil
{
if
err
==
nil
{
break
ch1
<-
true
return
}
}
UpdateFileError
(
"5"
,
v
.
Uuid
,
v
.
RoomNum
,
objectName
)
ch1
<-
false
return
}
else
{
ch1
<-
true
return
}
}(
file
)
}
}
for
i
:=
0
;
i
<
int
(
wordFloat64
);
i
++
{
t
:=
<-
ch1
if
t
{
uploadImageCount
++
}
}
return
err
})
//go func(file *zip.File) {
// defer debug.FreeOSMemory()
// err := pdfThumbnail(objectPath, file, bucket)
//
// if err != nil {
// fmt.Println(objectPath + file.Name + "上传失败")
// // 上传缩略图失败,重试3次
// for i := 0; i < 3; i++ {
// err = pdfThumbnail(objectPath, file, bucket)
// if err == nil {
// ch1 <- true
// return
// }
// }
// UpdateFileError("5", v.Uuid, v.RoomNum, objectName)
// ch1 <- false
// return
// } else {
// ch1 <- true
// return
// }
//
//}(file)
}
}
defer
reader
.
Close
()
//for i := 0; i < int(wordFloat64); i++ {
fmt
.
Println
(
uploadImageCount
,
wordFloat64
)
// t := <-ch1
if
uploadImageCount
!=
wordFloat64
{
// if t {
// uploadImageCount++
// }
//}
err
=
Pool
.
Wait
()
if
err
!=
nil
{
UpdateFileError
(
"5"
,
v
.
Uuid
,
v
.
RoomNum
,
objectName
)
UpdateFileError
(
"5"
,
v
.
Uuid
,
v
.
RoomNum
,
objectName
)
fmt
.
Println
(
"上传失败"
)
fmt
.
Println
(
err
)
return
return
}
}
defer
reader
.
Close
()
//fmt.Println(uploadImageCount, wordFloat64)
//if uploadImageCount != wordFloat64 {
// UpdateFileError("5", v.Uuid, v.RoomNum, objectName)
// fmt.Println("上传失败")
// return
//}
go
func
()
{
go
func
()
{
err
:=
uploadPacked
(
bucket
,
filename
,
contentHash
,
objectPath
,
err
:=
uploadPacked
(
bucket
,
filename
,
contentHash
,
objectPath
,
...
@@ -487,6 +509,7 @@ func CreateFileDataBase(room_file map[string]interface{}) error {
...
@@ -487,6 +509,7 @@ func CreateFileDataBase(room_file map[string]interface{}) error {
return
nil
return
nil
}
}
func
pdfThumbnail
(
objectPath
string
,
file
*
zip
.
File
,
bucket
*
oss
.
Bucket
)
error
{
func
pdfThumbnail
(
objectPath
string
,
file
*
zip
.
File
,
bucket
*
oss
.
Bucket
)
error
{
fc
,
err
:=
file
.
Open
()
fc
,
err
:=
file
.
Open
()
...
...
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