// NewFs constructs an Fs from the path, bucket:path
NewFs constructs an Fs from the path, bucket:path
// NewFs constructs an Fs from the path bucket : path
func NewFs(name, root string, m configmap.Mapper) (fs.Fs, error) {
	opt := new(Options)
	err := configstruct.Set(m, opt)
	if err != nil {
		return nil, err
	}
	err = checkUploadChunkSize(opt.ChunkSize)
	if err != nil {
		return nil, errors.Wrap(err, "qingstor: chunk size")
	}
	err = checkUploadCutoff(opt.UploadCutoff)
	if err != nil {
		return nil, errors.Wrap(err, "qingstor: upload cutoff")
	}
	bucket, key, err := qsParsePath(root)
	if err != nil {
		return nil, err
	}
	svc, err := qsServiceConnection(opt)
	if err != nil {
		return nil, err
	}
	if opt.Zone == "" {
		opt.Zone = "pek3a"
	}
	f := &Fs{
		name:   name,
		root:   key,
		opt:    *opt,
		svc:    svc,
		zone:   opt.Zone,
		bucket: bucket,
	}
	f.features = (&fs.Features{
		ReadMimeType:  true,
		WriteMimeType: true,
		BucketBased:   true,
	}).Fill(f)
	if f.root != "" {
		if !strings.HasSuffix(f.root, "/") {
			f.root += "/"
		}
		bucketInit, err := svc.Bucket(bucket, opt.Zone)
		if err != nil {
			return nil, err
		}
		_, err = bucketInit.HeadObject(key, &qs.HeadObjectInput{})
		if err == nil {
			f.root = path.Dir(key)
			if f.root == "." {
				f.root = ""
			} else {
				f.root += "/"
			}
			return f, fs.ErrorIsFile
		}
	}
	return f, nil
}
func NewFs ( name , root string , m configmap . Mapper ) ( fs . Fs , error ) { opt := new ( Options ) err := configstruct . Set ( m , opt ) if err != nil { return nil , err } err = checkUploadChunkSize ( opt . ChunkSize ) if err != nil { return nil , errors . Wrap ( err , " " ) } err = checkUploadCutoff ( opt . UploadCutoff ) if err != nil { return nil , errors . Wrap ( err , " " ) } bucket , key , err := qsParsePath ( root ) if err != nil { return nil , err } svc , err := qsServiceConnection ( opt ) if err != nil { return nil , err } if opt . Zone == " " { opt . Zone = " " } f := & Fs { name : name , root : key , opt : * opt , svc : svc , zone : opt . Zone , bucket : bucket , } f . features = ( & fs . Features { ReadMimeType : true , WriteMimeType : true , BucketBased : true , } ) . Fill ( f ) if f . root != " " { if ! strings . HasSuffix ( f . root , " " ) { f . root += " " } bucketInit , err := svc . Bucket ( bucket , opt . Zone ) if err != nil { return nil , err } _ , err = bucketInit . HeadObject ( key , & qs . HeadObjectInput { } ) if err == nil { f . root = path . Dir ( key ) if f . root == " " { f . root = " " } else { f . root += " " } return f , fs . ErrorIsFile } } return f , nil }
NewFs constructs an Fs from the path, bucket:path
NewFs constructs an Fs from the path bucket : path
// Parse config into Options struct //Check to see if the object exists // return an error with an fs which points to the parent