作者 yangfu

迁移修改

... ... @@ -96,6 +96,10 @@ func CreateUploadImage(client *vod.Client, r *CreateUploadImageRequest) (respons
filePath := getFileName(FileImage, r.FileName)
request.ImageType = "default"
request.Title = filePath
if filepath.Ext(r.FileName) == "" {
err = fmt.Errorf("filename:%v invalid", r.FileName)
return
}
request.ImageExt = filepath.Ext(r.FileName)[1:]
request.AcceptFormat = "JSON"
//request.StorageLocation = filepath.Base(request.Title)
... ...
... ... @@ -12,7 +12,7 @@ import (
"opp/protocol"
)
const LoopSize = 1
const LoopSize = 20
const (
Uploaded = "已上传,跳过"
... ... @@ -31,12 +31,13 @@ func MigrateChanceDataToAliYun() {
log.Info("【迁移机会媒体数据】开始迁移")
defer log.Info("【迁移机会媒体数据】结束迁移")
var (
datas []*models.ChanceData
query = `select * from chance_data order by id limit ?,?`
pageInfo = protocol.PageInfo{PageSize: LoopSize}
)
o := orm.NewOrm()
for {
var datas []*models.ChanceData
log.Info("当前页:", pageInfo.PageIndex, "起始:", pageInfo.Offset())
if _, e := o.Raw(query, pageInfo.Offset(), pageInfo.PageSize).QueryRows(&datas); e != nil {
if e == orm.ErrNoRows {
break
... ... @@ -44,6 +45,9 @@ func MigrateChanceDataToAliYun() {
log.Error(e)
break
}
if len(datas) == 0 {
break
}
for i := range datas {
data := datas[i]
... ... @@ -53,12 +57,12 @@ func MigrateChanceDataToAliYun() {
//上传视频
data.Videos = utils.JsonMarsh(uploadVideos(data, data.Videos))
//上传音频
data.Speechs = utils.JsonMarsh(uploadVoice(data, data.Speechs))
//data.Speechs = utils.JsonMarsh(uploadVoice(data, data.Speechs))
//更新数据
o.Update(data)
}
pageInfo.PageIndex += 1
break
//break
}
}
... ...