messages.go
func (m *MessageService) GetMediaURLs(ctx context.Context, sid string, data url.Values) ([]*url.URL, error) {
	page, err := m.client.Media.GetPage(ctx, sid, data)
	if err != nil {
		return nil, err
	}
	if len(page.MediaList) == 0 {
		urls := make([]*url.URL, 0, 0)
		return urls, nil
	}
	urls := make([]*url.URL, len(page.MediaList))
	errs := make([]error, len(page.MediaList))
	var wg sync.WaitGroup
	wg.Add(len(page.MediaList))
	for i, media := range page.MediaList {
		go func(i int, media *Media) {
			url, err := m.client.Media.GetURL(ctx, sid, media.Sid)
			urls[i] = url
			errs[i] = err
			wg.Done()
		}(i, media)
	}
	wg.Wait()
	// todo - we could probably return more quickly in the result of a failure.
	for _, err := range errs {
		if err != nil {
			return nil, err
		}
	}
	return urls, nil
}
func (m *MessageService) GetMediaURLs(ctx context.Context, sid string, data url.Values) ([]*url.URL, error) {
	page, err := m.client.Media.GetPage(ctx, sid, data)
	if err != nil {
		return nil, err
	}
	if len(page.MediaList) == 0 {
		urls := make([]*url.URL, 0, 0)
		return urls, nil
	}
	urls := make([]*url.URL, len(page.MediaList))
	errs := make([]error, len(page.MediaList))
	var wg sync.WaitGroup
	wg.Add(len(page.MediaList))
	for i, media := range page.MediaList {
		go func(i int, media *Media) {
			url, err := m.client.Media.GetURL(ctx, sid, media.Sid)
			urls[i] = url
			errs[i] = err
			wg.Done()
		}(i, media)
	}
	wg.Wait()
	// todo - we could probably return more quickly in the result of a failure.
	for _, err := range errs {
		if err != nil {
			return nil, err
		}
	}
	return urls, nil
}
func ( m * MessageService ) GetMediaURLs ( ctx context . Context , sid string , data url . Values ) ( [ ] * url . URL , error ) { page , err := m . client . Media . GetPage ( ctx , sid , data ) if err != nil { return nil , err } if len ( page . MediaList ) == 0 { urls := make ( [ ] * url . URL , 0 , 0 ) return urls , nil } urls := make ( [ ] * url . URL , len ( page . MediaList ) ) errs := make ( [ ] error , len ( page . MediaList ) ) var wg sync . WaitGroup wg . Add ( len ( page . MediaList ) ) for i , media := range page . MediaList { go func ( i int , media * Media ) { url , err := m . client . Media . GetURL ( ctx , sid , media . Sid ) urls [ i ] = url errs [ i ] = err wg . Done ( ) } ( i , media ) } wg . Wait ( ) // todo - we could probably return more quickly in the result of a failure. for _ , err := range errs { if err != nil { return nil , err } } return urls , nil }
// GetMediaURLs gets the URLs of any media for this message. This uses threads
// to retrieve all URLs simultaneously; if retrieving any URL fails, we return
// an error for the entire request.
//
// The data can be used to filter the list of returned Media as described here:
// https://www.twilio.com/docs/api/rest/media#list-get-filters
//
// As of October 2016, only 10 MediaURLs are permitted per message. No attempt
// is made to page through media resources; omit the PageSize parameter in
// data, or set it to a value greater than 10, to retrieve all resources.
GetMediaURLs gets the URLs of any media for this message . This uses threads to retrieve all URLs simultaneously ; if retrieving any URL fails we return an error for the entire request . The data can be used to filter the list of returned Media as described here : https : // www . twilio . com / docs / api / rest / media#list - get - filters As of October 2016 only 10 MediaURLs are permitted per message . No attempt is made to page through media resources ; omit the PageSize parameter in data or set it to a value greater than 10 to retrieve all resources .