-
-
Save c-nv-s/11365d54fa58bcfca1968f16aab8b29a to your computer and use it in GitHub Desktop.
Recombine file chunks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
chunkSizeInBytes := 1048576 | |
chunksDir := "/path/to/uploads/temp/3203610240-WildifeTactics" | |
/* | |
Generate an empty file | |
*/ | |
f, err := os.Create("testfile.mp4") | |
if err != nil { | |
fmt.Printf("Error: %s", err) | |
} | |
defer f.Close() | |
//For every chunk, write it to the empty file. The number of iterations is determined from resumable.js | |
for i := 1; i <= 3055; i++ { | |
relativePath := fmt.Sprintf("%s%s%d", chunksDir, "/part", i) | |
fmt.Println("Chnk path: " + relativePath) | |
writeOffset := int64(chunkSizeInBytes * (i - 1)) | |
if i == 1 { | |
writeOffset = 0 | |
} | |
dat, err := ioutil.ReadFile(relativePath) | |
size, err := f.WriteAt(dat, writeOffset) | |
if err != nil { | |
fmt.Printf("Error: %s", err) | |
} | |
fmt.Printf("%d bytes written offset %d \n", size, writeOffset) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment