// TODO 하위 폴더로 정리해서 업로드하는게 필요해질지 모른다 func UploadMetadata(t *anaconda.Tweet, accessor storages.Accessor, path string, now time.Time) (UploadMetadataResponse, error) { id := t.IdStr filename := MakeTweetFileName(id, now) e := accessor.UploadJson(t, filename) resp := UploadMetadataResponse{ ID: id, FileName: filename, } return resp, e }
func save(tweet *anaconda.Tweet, mediaRespList []*MediaResponse, accessor storages.Accessor) { now := time.Now() resp, e := twutils.UploadMetadata(tweet, accessor, "", now) if e != nil { log.Fatalf("Save Tweet Fail! %s -> %s, [%s]", resp.ID, resp.FileName, e.Error()) } else { log.Printf("Save Tweet %s -> %s", resp.ID, resp.FileName) } // upload media for _, resp := range mediaRespList { filename := twutils.MakeNormalFileName(resp.FileName, now) err := accessor.UploadBytes(resp.Response.Data, filename) if err != nil { log.Fatalf("Save Image Fail! %s -> %s, [%s]", tweet.IdStr, filename, err.Error()) } else { log.Printf("Save Image %s -> %s", tweet.IdStr, filename) } } }