// Update the Object from in with modTime and size
Update the Object from in with modTime and size
// Update the Object from in with modTime and size
func (o *Object) Update(in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) error {
	err := o.fs.Mkdir("")
	if err != nil {
		return err
	}
	modTime := src.ModTime()
	size := src.Size()
	uploader := s3manager.NewUploader(o.fs.ses, func(u *s3manager.Uploader) {
		u.Concurrency = o.fs.opt.UploadConcurrency
		u.LeavePartsOnError = false
		u.S3 = o.fs.c
		u.PartSize = int64(o.fs.opt.ChunkSize)
		if size == -1 {
			u.PartSize = (((maxFileSize / s3manager.MaxUploadParts) >> 20) + 1) << 20
			return
		}
		if size/u.PartSize >= s3manager.MaxUploadParts {
			u.PartSize = (((size / s3manager.MaxUploadParts) >> 20) + 1) << 20
		}
	})
	metadata := map[string]*string{
		metaMtime: aws.String(swift.TimeToFloatString(modTime)),
	}
	if !o.fs.opt.DisableChecksum && size > uploader.PartSize {
		hash, err := src.Hash(hash.MD5)
		if err == nil && matchMd5.MatchString(hash) {
			hashBytes, err := hex.DecodeString(hash)
			if err == nil {
				metadata[metaMD5Hash] = aws.String(base64.StdEncoding.EncodeToString(hashBytes))
			}
		}
	}
	mimeType := fs.MimeType(src)
	key := o.fs.root + o.remote
	req := s3manager.UploadInput{
		Bucket:      &o.fs.bucket,
		ACL:         &o.fs.opt.ACL,
		Key:         &key,
		Body:        in,
		ContentType: &mimeType,
		Metadata:    metadata,
	}
	if o.fs.opt.ServerSideEncryption != "" {
		req.ServerSideEncryption = &o.fs.opt.ServerSideEncryption
	}
	if o.fs.opt.SSEKMSKeyID != "" {
		req.SSEKMSKeyId = &o.fs.opt.SSEKMSKeyID
	}
	if o.fs.opt.StorageClass != "" {
		req.StorageClass = &o.fs.opt.StorageClass
	}
	_, err = uploader.Upload(&req)
	if err != nil {
		return err
	}
	o.meta = nil 
	err = o.readMetaData()
	return err
}
func ( o * Object ) Update ( in io . Reader , src fs . ObjectInfo , options ... fs . OpenOption ) error { err := o . fs . Mkdir ( " " ) if err != nil { return err } modTime := src . ModTime ( ) size := src . Size ( ) uploader := s3manager . NewUploader ( o . fs . ses , func ( u * s3manager . Uploader ) { u . Concurrency = o . fs . opt . UploadConcurrency u . LeavePartsOnError = false u . S3 = o . fs . c u . PartSize = int64 ( o . fs . opt . ChunkSize ) if size == - 1 { u . PartSize = ( ( ( maxFileSize / s3manager . MaxUploadParts ) >> 20 ) + 1 ) << 20 return } if size / u . PartSize >= s3manager . MaxUploadParts { u . PartSize = ( ( ( size / s3manager . MaxUploadParts ) >> 20 ) + 1 ) << 20 } } ) metadata := map [ string ] * string { metaMtime : aws . String ( swift . TimeToFloatString ( modTime ) ) , } if ! o . fs . opt . DisableChecksum && size > uploader . PartSize { hash , err := src . Hash ( hash . MD5 ) if err == nil && matchMd5 . MatchString ( hash ) { hashBytes , err := hex . DecodeString ( hash ) if err == nil { metadata [ metaMD5Hash ] = aws . String ( base64 . StdEncoding . EncodeToString ( hashBytes ) ) } } } mimeType := fs . MimeType ( src ) key := o . fs . root + o . remote req := s3manager . UploadInput { Bucket : & o . fs . bucket , ACL : & o . fs . opt . ACL , Key : & key , Body : in , ContentType : & mimeType , Metadata : metadata , } if o . fs . opt . ServerSideEncryption != " " { req . ServerSideEncryption = & o . fs . opt . ServerSideEncryption } if o . fs . opt . SSEKMSKeyID != " " { req . SSEKMSKeyId = & o . fs . opt . SSEKMSKeyID } if o . fs . opt . StorageClass != " " { req . StorageClass = & o . fs . opt . StorageClass } _ , err = uploader . Upload ( & req ) if err != nil { return err } o . meta = nil err = o . readMetaData ( ) return err }
Update the Object from in with modTime and size
Update the Object from in with modTime and size
// Make parts as small as possible while still being able to upload to the // S3 file size limit. Rounded up to nearest MB. // Adjust PartSize until the number of parts is small enough. // Calculate partition size rounded up to the nearest MB // Set the mtime in the meta data // Guess the content type //ContentLength: &size, // Read the metadata from the newly created object // wipe old metadata