Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upload/download large files #115

Open
lll-phill-lll opened this issue Aug 29, 2018 · 4 comments
Open

upload/download large files #115

lll-phill-lll opened this issue Aug 29, 2018 · 4 comments
Labels

Comments

@lll-phill-lll
Copy link

lll-phill-lll commented Aug 29, 2018

Hello,
I try to understand how to use the library, but I can't even after reading testing files.
Can you provide an example of code for uploading and downloading large file (> 5gb)?

func Upload() {
	conn := swift.Connection{
		UserName: "<username>",
		ApiKey:   "<key>",
		AuthUrl:  "https://identity.api.rackspacecloud.com/v1.0/",
		Region:   "<region>",
	}
	err := conn.Authenticate()
	if err != nil {
		fmt.Println(err)
	}
	opts := swift.LargeObjectOpts{
		Container:  "<container_name>",
		ObjectName: "fileName.txt",
		ChunkSize:  5,
		CheckHash:  true,
	}

	file, err := conn.StaticLargeObjectCreate(&opts)
	if err != nil {
		fmt.Println(err)
	}

	localFile, err := os.Open("FileToUpload.txt")
	if err != nil {
		fmt.Println(err)
	}
	defer localFile.Close()

	_, err = io.Copy(file, localFile)
	if err != nil {
		fmt.Println(err) // Generates error "Object not found"
	}
	err = file.Close()
	if err != nil {
		fmt.Println("cant close", err) // Generates error "Object not found"
	}
}

I'm using this code, but it fails with error "Object not found".
Hope for your help. Thank you!

@ncw
Copy link
Owner

ncw commented Sep 4, 2018

I can't see anything obviously wrong with your code.

I suspect this is to do with swift eventual consistency...

You are using a very small ChunkSize which means swift will create lots of objects very quickly and have trouble listing them back.

Try using a larger ChunkSize (say 100MB) and uploading a bigger file?

Which provider are you using?

@ncw ncw added the question label Sep 4, 2018
@taotiepp
Copy link

Me too.I use the swift API provided by CEPH radosgw.

@zhaokai5520
Copy link

download large files oom

@spatialbits
Copy link

spatialbits commented Sep 18, 2023

The 404 may be because the segments container is missing. It will automatically look for a [containerNamer]_segments container to put the segments in and will fail with a 404 if it's not there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants